Re: [xsl] Using sibling value in streaming mode

Subject: Re: [xsl] Using sibling value in streaming mode
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 31 Aug 2019 08:36:33 -0000
Am 31.08.2019 um 10:25 schrieb Michael Kay mike@xxxxxxxxxxxx:
If you want to achieve some level of streaming within the map, then
clearly it's not going to be perfect streaming; in the worst case, if
the "id" comes last, then you're going to have to buffer something in
memory. Burst-mode streaming buffers the input in memory; an
alternative is to buffer the output, which you can achieve using xsl:fork:

<xsl:template match="map" mode="streamed">
B  B <xsl:fork>
B  B  B <xsl:sequence>
B  B  B  B  <id>{string[@key='id']}</id>
B  B  B <xsl:sequence>
B  B  B <xsl:sequence>
B  B  B  B  <xsl:apply-templates select="string[not(@key='id')]"
mode="streamed"/>
B  B  B <xsl:sequence>
B  B </xsl:fork>
</xsl:template>



Does xsl:fork as outlined above really help for the below wanted output where you need the "id" to construct the "item" for each of the string[not(@key='id')] elements?

Required output:

<items>
B B B <item>
B B B B B B <id>123456789</id>
B B B B B B <key>key1<key>
B B B B B B <val>value1</val>
B B B </item>
B B B ...
B B B <item>
B B B B B B <id>123456789</id>
B B B B B B <key>id<key>
B B B B B B <val>123456789</val>
B B B </item>
B B B ...
B B B <item>
B B B B B B <id>123456789</id>
B B B B B B <key>keyN<key>
B B B B B B <val>valueN</val>
B B B </item>
B B B ...
</items>

The value of <string key="id"> is used as <id> in <item> elements. The
problem is that <string key="id"> can occur in any position in the
<map>.

Current Thread