Subject: Re: [xsl] streaming XSLT creating a header from a first record From: "Geert Bormans geert@xxxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 15 May 2018 13:17:46 -0000 |
still trying to get my head around this and facing obstacles, most likely by lack of understanding... however example in <table> <row id="row1" attr1="A" attr2="AA"/> <row id="row2" attr1="C" attr2="CC"/> <row id="row3" attr1="D" attr2="DD"/> </table> example out <document> <header> <!-- process first row here --> <id>row1</id> <attr1>A</attr1> <attr2>AA</attr2> </header> <content> <!-- process all including first row here --> <row id="row1" attr1="A" attr2="AA"/> <row id="row2" attr1="C" attr2="CC"/> <row id="row3" attr1="D" attr2="DD"/> </content> </document> Using the accumulator or the xsl:iterate approach allows me to process the header row twice but I can't seem to figure out to create the header and then continue the iteration in a different construct it seems I need the header always before the iterator has started Feels close, but no sigar Thanks Best regards, Geert Bormans -------------------------------------------------------------- Markup UK - a conference about XML and other mark-up languages London, June 9b10 2018 Programme now available at [ http://markupuk.org/speakers.xhtml | http://markupuk.org/speakers.xhtml ] Register at [ http://markupuk.org/registration.xhtml | http://markupuk.org/registration.xhtml ] ----- Oorspronkelijk bericht ----- Van: "Abel Braaksma, (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Aan: "xsl-list" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Verzonden: Dinsdag 8 mei 2018 20:11:09 Onderwerp: Re: [xsl] streaming XSLT creating a header from a first record On 08.05.2018 18:04, Michael Kay mike@xxxxxxxxxxxx wrote: > I don't think you need two accumulators, you can have a single accumulator that matches every row and only creates the map if the current value is an empty map. Taking up that idea I tried also to construct a streaming accumulator that stores a (shallow) copy of the first row element and a deep copy of its attributes: <xsl:accumulator name="first-row-copy" as="element(row)?" initial-value="()" streamable="yes"> <xsl:accumulator-rule match="table/row"> <xsl:choose> <xsl:when test="empty($value)"> <xsl:copy> <xsl:copy-of select="@*"/> </xsl:copy> </xsl:when> <xsl:otherwise> <xsl:sequence select="$value"/> </xsl:otherwise> </xsl:choose> </xsl:accumulator-rule> </xsl:accumulator> Seems to also work fine. So in that case one doesn't need to switch between XML and maps when processing the stored value but can continue to use the traditional XSLT processing of XML.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] streaming XSLT creating a, Martin Honnen martin | Thread | Re: [xsl] streaming XSLT creating a, Martin Honnen martin |
Re: [xsl] Getting text nodes from t, David Carlisle d.p.c | Date | Re: [xsl] streaming XSLT creating a, Martin Honnen martin |
Month |