[xsl] Using sibling value in streaming mode

Subject: [xsl] Using sibling value in streaming mode
From: "Martynas Jusevičius martynas@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Aug 2019 21:18:32 -0000

I've started looking into streaming recently (using Saxon 9.9). I have
a use case like this:


       <string key="key1">value1</string>
       <string key="id">123456789</string>
       <string key="keyN">valueN</string>

Required output:


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

I've tried using an accumulator such as

<xsl:accumulator name="map-id" initial-value="()" streamable="yes"
   <xsl:accumulator-rule match="/array/map/string[@key = 'id']/text()"

and then

    <id><xsl:value-of select="accumulator-before('map-id')"/></id>

That worked partially -- only for sibling <string> elements that
followed the <string key="id">. Which is not surprising.

I've also tried accumulator-after('map-id') but got:

  XTSE3430: Template rule is not streamable
  * A call to accumulator-after() is consuming when there are no
preceding consuming instructions

Is it possible to have a streaming solution in this case?


Current Thread