|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: getting result documents out of a function that ca
On Wed, Mar 31, 2021 at 06:46:05PM -0000, Liam R. E. Quin liam@xxxxxxxxxxxxxxxx scripsit:
> On Wed, 2021-03-31 at 18:26 +0000, Graydon graydon@xxxxxxxxx wrote:
> > How do I get those DEBUG result documents back out of the function?
>
> You probably do need to have your function take a map as an argument.
> A sequence of "documents-so-far" is even less elegant when you start
> dealing with where to write them out to.
For posterity:
<xd:doc>
<xd:desc>process transformation events in list order with fetched params</xd:desc>
<xd:param name="initial">the document we're going to transform</xd:param>
<xd:param name="list">the list of transformation event names we need to process</xd:param>
<xd:param name="results">the accumulating return values of the successive transform() calls</xd:param>
</xd:doc>
<xsl:function name="local:processList" as="map(*)">
<xsl:param as="document-node()" name="initial" />
<xsl:param as="xs:string*" name="list" />
<xsl:param as="map(*)" name="results" />
<xsl:choose>
<xsl:when test="not(exists($list))">
<!-- no more event names to process, so stop and return what we were called with -->
<xsl:sequence select="map:merge((map:entry('processed',$initial),$results))" />
</xsl:when>
<xsl:otherwise>
<!-- we still have events to process -->
<xsl:variable name="temp" as="map(*)" select="transform(
map:merge(
($transformMap(head($list)),
map:entry('source-node', $initial))
)
)"/>
<!-- when we add this transform result, remove the output key because that will duplicate -->
<xsl:sequence select="
local:processList($temp?output,tail($list),map:merge(($results,map:remove($temp,'output')))
)" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
Not elegant, but functional.
I think it would be helpful for map:merge() to throw a warning if the
second argument doesn't contain any recognizable option names.
Thanks!
--
Graydon Saunders | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor ("That passed, so may this.")
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








