Tests based on streamed grouping bugs in Saxon
authorMichael Kay <mike@saxonica.com>
Tue, 08 Aug 2017 17:55:21 +0100
changeset 1736 5d237a457819
parent 1735 2d07e517a7e9
child 1737 c7584e81c04e
Tests based on streamed grouping bugs in Saxon
tests/strm/si-for-each-group/_si-for-each-group-test-set.xml
tests/strm/si-fork/_si-fork-test-set.xml
tests/strm/si-fork/si-fork-808.xml
tests/strm/si-fork/si-fork-808.xsl
--- a/tests/strm/si-for-each-group/_si-for-each-group-test-set.xml	Tue Aug 08 17:54:04 2017 +0100
+++ b/tests/strm/si-for-each-group/_si-for-each-group-test-set.xml	Tue Aug 08 17:55:21 2017 +0100
@@ -1233,6 +1233,7 @@
    <test-case name="si-group-060">
       <description>Streamed grouping - average of attribute values in group.</description>
       <created by="Michael Kay after Martin Honnen" on="2017-07-13"/>
+      <modified by="Michael Kay" on="2017-08-08" change="add expected results"/>
       <environment>
          <source file="si-group-060.xml" role="." streaming="true"/>
       </environment>
@@ -1241,7 +1242,9 @@
       </test>
       <result>
          <all-of>
-            <assert-xml><![CDATA[<Element>TBA</Element>]]></assert-xml>
+            <assert>/out/p[1] = 'Milano, Italia, 5.26'</assert>
+            <assert>/out/p[2] = 'Padova, Italia, 0.81'</assert>
+            <assert>/out/p[3] = 'Paris, France, 7.4'</assert>
          </all-of>
       </result>
    </test-case>
@@ -1257,7 +1260,9 @@
       </test>
       <result>
          <all-of>
-            <assert-xml><![CDATA[<Element>TBA</Element>]]></assert-xml>
+            <assert>/out/p[1] = 'Milano, Italia, 5.23, 5.29'</assert>
+            <assert>/out/p[2] = 'Padova, Italia, 0.69, 0.93'</assert>
+            <assert>/out/p[3] = 'Paris, France, 7.2, 7.6'</assert>
          </all-of>
       </result>
    </test-case>
--- a/tests/strm/si-fork/_si-fork-test-set.xml	Tue Aug 08 17:54:04 2017 +0100
+++ b/tests/strm/si-fork/_si-fork-test-set.xml	Tue Aug 08 17:55:21 2017 +0100
@@ -614,6 +614,20 @@
       </result>
    </test-case>
    
+   <test-case name="si-fork-808">
+      <description>Streamable xsl:fork containing xsl:for-each-group (Saxon bug 3375)</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-08-07"/>
+      <environment>
+         <source role="." file="si-fork-808.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-fork-808.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<TBA/>]]></assert-xml>
+      </result>
+   </test-case>
+   
    <test-case name="si-fork-901">
       <description>Non-streamable xsl:fork - returns streamed nodes</description>
       <keywords>multiple-xsl-sequence-children AxisStep striding XTSE3430 illegally-returning-streamed-nodes</keywords>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-808.xml	Tue Aug 08 17:55:21 2017 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+    <p class="l1">   (a)<tab/>blah blah</p>
+    <p class="l2">   (i)<tab/>blah blah</p>
+    <p class="l1">   (b)<tab/>blah blah</p>
+    <p class="l1">   (c)<tab/>blah blah</p>
+    <p class="l2">   (i)<tab/>blah blah</p>
+    <p class="l3">   (1)<tab/>blah blah</p>
+    <p class="l3">   (2)<tab/>blah blah</p>
+    <p class="l2">   (ii)<tab/>blah blah</p>
+    <p class="l2">   (iii)<tab/>blah blah</p>
+    <p class="l2">   (iv)<tab/>blah blah</p>
+</root>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-808.xsl	Tue Aug 08 17:55:21 2017 +0100
@@ -0,0 +1,54 @@
+<?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" 
+    xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:mf="http://example.com/mf" 
+    exclude-result-prefixes="xs math mf" version="3.0">
+    
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+    
+    <xsl:param name="prefix" as="xs:string" select="'l'"/>
+    
+    <xsl:mode _streamable="{$STREAMABLE}" on-no-match="shallow-copy"/>
+    
+    <xsl:mode name="num" _streamable="{$STREAMABLE}"/>
+    
+    <xsl:output indent="yes"/>
+    
+    <xsl:function name="mf:nest" as="node()*" 
+        _streamability="{if ($STREAMABLE) then 'absorbing' else 'unclassified'}">
+        <xsl:param name="input" as="node()*"/>
+        <xsl:param name="level" as="xs:integer"/>
+        <xsl:where-populated>
+            <orderlist type="manual">
+                <xsl:for-each-group select="$input" 
+                    group-starting-with="*[@class = $prefix || $level]">
+                    <item>
+                        <xsl:fork>
+                            <xsl:sequence>
+                                <xsl:apply-templates select="node()[1]" mode="num"/>
+                            </xsl:sequence>
+                            <xsl:sequence>
+                                <para>
+                                    <xsl:apply-templates select="node()[position() gt 2]"/>
+                                </para>                               
+                            </xsl:sequence>
+                            <xsl:sequence select="mf:nest(current-group()[position() gt 1], $level + 1)" 
+                            />
+                        </xsl:fork>                     
+                    </item>
+                </xsl:for-each-group>
+            </orderlist>
+        </xsl:where-populated>
+    </xsl:function>
+    
+    <xsl:template match="root">
+        <xsl:copy>
+            <xsl:sequence select="mf:nest(*, 1)"/>
+        </xsl:copy>
+    </xsl:template>
+    
+    <xsl:template match="*[matches(@class, $prefix || '[0-9]+')]/node()" mode="num">
+        <xsl:attribute name="num" select="replace(., '^\s+', '')"/>
+    </xsl:template>
+    
+</xsl:stylesheet>
\ No newline at end of file