Project

Profile

Help

Bug #4561

XSLT 3 with recursive, streamable function passes the streamability analysis but output is different from non-streamed execution

Added by Martin Honnen 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Streaming
Sprint/Milestone:
-
Start date:
2020-05-26
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
10, 9.9
Fix Committed on Branch:
Fixed in Maintenance Release:

Description

I tried myself again on a streamable stylesheet function, it passes the streamability analysis with both Saxon EE 9.9.17 and 10.1 but doesn't output the same result as when turning streaming off.

The code is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="#all"
    xmlns:mf="http://example.com/mf"
    version="3.0">
    
    <xsl:output indent="yes"/>
    
    <xsl:mode on-no-match="shallow-copy" streamable="yes"/>
    
    <xsl:function name="mf:nest" as="element()?" streamability="absorbing">
        <xsl:param name="elements" as="element()*"/>
        <xsl:copy select="head($elements)">
            <xsl:attribute name="type">data</xsl:attribute>
            <xsl:sequence select="mf:nest(tail($elements))"/>
        </xsl:copy>
    </xsl:function>
    
    <xsl:template match="person">
        <xsl:copy>
            <xsl:sequence select="mf:nest(*)"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

an input sample is

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <person>
        <a/>
        <b/>
        <c/>
        <d/>
    </person>

    <person>
        <a/>
        <b/>
        <c/>
        <d/>
    </person>
</root>

without streaming I get the intended complete nesting of the siblings of the input person elements

<root>
   <person>
      <a type="data">
         <b type="data">
            <c type="data">
               <d type="data"/>
            </c>
         </b>
      </a>
   </person>
   <person>
      <a type="data">
         <b type="data">
            <c type="data">
               <d type="data"/>
            </c>
         </b>
      </a>
   </person>
</root>

with streaming the deeper nested elements in the result are missing:

<root>
   <person>
      <a type="data"/>
   </person>
   <person>
      <a type="data"/>
   </person>
</root>
head-tail-recursive-function1-streaming.xsl (852 Bytes) head-tail-recursive-function1-streaming.xsl Martin Honnen, 2020-05-26 14:08
input1.xml (217 Bytes) input1.xml Martin Honnen, 2020-05-26 14:08

Please register to edit this issue

Also available in: Atom PDF