xsl-list
[Top] [All Lists]

Re: [xsl] Using sibling value in streaming mode

2019-08-31 03:36:38
Am 31.08.2019 um 10:25 schrieb Michael Kay mike(_at_)saxonica(_dot_)com:
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">
   <xsl:fork>
     <xsl:sequence>
        <id>{string[@key='id']}</id>
     <xsl:sequence>
     <xsl:sequence>
        <xsl:apply-templates select="string[not(@key='id')]"
mode="streamed"/>
     <xsl:sequence>
   </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>
   <item>
      <id>123456789</id>
      <key>key1<key>
      <val>value1</val>
   </item>
   ...
   <item>
      <id>123456789</id>
      <key>id<key>
      <val>123456789</val>
   </item>
   ...
   <item>
      <id>123456789</id>
      <key>keyN<key>
      <val>valueN</val>
   </item>
   ...
</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>.

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>