More streamed grouping tests
authorMichael Kay <mike@saxonica.com>
Mon, 18 Sep 2017 23:30:06 +0100
changeset 1758 6380162df04c
parent 1757 42a8d79bce60
child 1759 97eef08c8f1d
More streamed grouping tests
tests/strm/si-fork/_si-fork-test-set.xml
tests/strm/si-fork/si-fork-808.xsl
tests/strm/si-fork/si-fork-809.xml
tests/strm/si-fork/si-fork-809.xsl
tests/strm/si-fork/si-fork-810.xsl
tests/strm/si-fork/si-fork-811.xsl
--- a/tests/strm/si-fork/_si-fork-test-set.xml	Mon Sep 18 23:29:15 2017 +0100
+++ b/tests/strm/si-fork/_si-fork-test-set.xml	Mon Sep 18 23:30:06 2017 +0100
@@ -636,6 +636,63 @@
       </result>
    </test-case>
    
+   <test-case name="si-fork-809">
+      <description>Streamable xsl:fork containing xsl:for-each-group (Saxon bug 3399)</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-08-31"/>
+      <environment>
+         <source role="." file="si-fork-809.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-fork-809.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>count(/out/text()) = 12</assert>
+            <assert>/out/text()[1] = "Comedy, New, Paperback, 3"</assert>
+            <assert>/out/text()[2] = "Comedy, Old, Paperback, 3"</assert>
+            <assert>/out/text()[3] = "Comedy, New, Hardback, 3"</assert>
+            <assert>/out/text()[4] = "Comedy, Old, Hardback, 3"</assert>
+            <assert>/out/text()[5] = "Drama, New, Paperback, 3"</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="si-fork-810">
+      <description>Streamable xsl:fork containing xsl:for-each-group (Saxon bug 3375) - simplified version of -808</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-08-31"/>
+      <environment>
+         <source role="." file="si-fork-808.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-fork-810.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/root/orderlist/item[@num="(a)"]/rest/@size = "2"</assert>
+            <assert>/root/orderlist/item[@num="(b)"]/rest/@size = "1"</assert>
+            <assert>/root/orderlist/item[@num="(c)"]/rest/@size = "7"</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="si-fork-811">
+      <description>Streamable xsl:fork containing xsl:for-each-group (Saxon bug 3375) - simplified version of -808</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-08-31"/>
+      <environment>
+         <source role="." file="si-fork-808.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-fork-811.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/root/orderlist/item[@num="(a)"]/rest/@size = "1"</assert>
+            <assert>/root/orderlist/item[@num="(b)"]/rest/@size = "0"</assert>
+            <assert>/root/orderlist/item[@num="(c)"]/rest/@size = "6"</assert>
+         </all-of>
+      </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>
--- a/tests/strm/si-fork/si-fork-808.xsl	Mon Sep 18 23:29:15 2017 +0100
+++ b/tests/strm/si-fork/si-fork-808.xsl	Mon Sep 18 23:30:06 2017 +0100
@@ -16,7 +16,7 @@
         _streamability="{if ($STREAMABLE) then 'absorbing' else 'unclassified'}">
         <xsl:param name="input" as="node()*"/>
         <xsl:param name="level" as="xs:integer"/>
-        <xsl:where-populated>
+        <!--<xsl:where-populated>-->
             <orderlist type="manual">
                 <xsl:for-each-group select="$input" 
                     group-starting-with="*[@class = $prefix || $level]">
@@ -30,13 +30,12 @@
                                     <xsl:apply-templates select="node()[position() gt 2]"/>
                                 </para>                               
                             </xsl:sequence>
-                            <xsl:sequence select="mf:nest(current-group()[position() gt 1], $level + 1)" 
-                            />
+                            <xsl:sequence select="mf:nest(current-group()[position() gt 1], $level + 1)"/>                            
                         </xsl:fork>                     
                     </item>
                 </xsl:for-each-group>
             </orderlist>
-        </xsl:where-populated>
+        <!--</xsl:where-populated>-->
     </xsl:function>
     
     <xsl:template match="root">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-809.xml	Mon Sep 18 23:30:06 2017 +0100
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Data>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Comedy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Drama" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Paperback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="New" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+    <Entry Genre="Fantasy" 
+        Condition="Old" 
+        Format="Hardback" 
+        Title="foo" 
+        Count="1"/>
+</Data>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-809.xsl	Mon Sep 18 23:30:06 2017 +0100
@@ -0,0 +1,24 @@
+<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" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:param name="STREAMABLE" as="xs:boolean" static="yes" select="true()"/>
+    
+    <xsl:mode _streamable="{$STREAMABLE}"/>
+    
+    <xsl:output method="text"/>
+    
+    <xsl:template match="/">
+        <out>
+          <xsl:fork>
+            <xsl:for-each-group select="Data/Entry" composite="yes" group-by="@Genre, @Condition, @Format">
+                <xsl:value-of select="current-grouping-key(), sum(current-group()/@Count)" separator=", "/>
+                <br/>
+            </xsl:for-each-group>
+          </xsl:fork>
+        </out>
+    </xsl:template>
+    
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-810.xsl	Mon Sep 18 23:30:06 2017 +0100
@@ -0,0 +1,53 @@
+<?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: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>
+                                <rest size="{count(current-group())}"/>
+                            </xsl:sequence>
+                        </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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-811.xsl	Mon Sep 18 23:30:06 2017 +0100
@@ -0,0 +1,53 @@
+<?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: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>
+                                <rest size="{count(current-group()[position() gt 1])}"/>
+                            </xsl:sequence>
+                        </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