More streamed grouping tests
authorMichael Kay <mike@saxonica.com>
Wed, 26 Jul 2017 13:48:57 +0100
changeset 1729 cf7de651f4ef
parent 1728 c010bd2cd0ac
child 1730 9243f955992e
More streamed grouping tests
tests/strm/si-for-each-group/_si-for-each-group-test-set.xml
tests/strm/si-for-each-group/si-group-060.xml
tests/strm/si-for-each-group/si-group-060.xsl
tests/strm/si-for-each-group/si-group-061.xsl
tests/strm/si-fork/_si-fork-test-set.xml
tests/strm/si-fork/si-fork-806.xml
tests/strm/si-fork/si-fork-806.xsl
tests/strm/si-fork/si-fork-807.xsl
--- a/tests/strm/si-for-each-group/_si-for-each-group-test-set.xml	Wed Jul 26 13:48:12 2017 +0100
+++ b/tests/strm/si-for-each-group/_si-for-each-group-test-set.xml	Wed Jul 26 13:48:57 2017 +0100
@@ -1230,6 +1230,38 @@
       </result>
    </test-case>
    
+   <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"/>
+      <environment>
+         <source file="si-group-060.xml" role="." streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-group-060.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert-xml><![CDATA[<Element>TBA</Element>]]></assert-xml>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="si-group-061">
+      <description>Streamed grouping - average of attribute values in group.</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-07-13"/>
+      <environment>
+         <source file="si-group-060.xml" role="." streaming="true"/> <!-- sic -->
+      </environment>
+      <test>
+         <stylesheet file="si-group-061.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert-xml><![CDATA[<Element>TBA</Element>]]></assert-xml>
+         </all-of>
+      </result>
+   </test-case>
+   
    <test-case name="si-group-059a">
       <description>Streamed grouping - conditional within xsl:for-each-group (variant of -059 with different source document).</description>
       <created by="Michael Kay" on="2017-07-06"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-for-each-group/si-group-060.xml	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cities>
+    <city name="Milano"  country="Italia"  year="1950"   pop="5.23"/>
+    <city name="Milano"  country="Italia"  year="1960"   pop="5.29"/>  
+    <city name="Padova"  country="Italia"  year="1950"   pop="0.69"/>
+    <city name="Padova"  country="Italia"  year="1960"   pop="0.93"/>    
+    <city name="Paris"   country="France"  year="1951"   pop="7.2"/>
+    <city name="Paris"   country="France"  year="1961"   pop="7.6"/>
+</cities>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-for-each-group/si-group-060.xsl	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,28 @@
+<?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" exclude-result-prefixes="xs math"
+    version="3.0">
+
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+
+    <xsl:mode _streamable="{$STREAMABLE}"/>
+
+    <xsl:template match="/">
+        <out>
+            <xsl:apply-templates/>
+        </out>
+    </xsl:template>
+
+    <xsl:template match="cities">
+
+        <xsl:for-each-group select="city" group-adjacent="@name, @country" composite="yes">
+            <p>
+                <xsl:value-of select="current-grouping-key(), avg(current-group()/@pop)"
+                    separator=", "/>
+            </p>
+        </xsl:for-each-group>
+
+    </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-for-each-group/si-group-061.xsl	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,29 @@
+<?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" exclude-result-prefixes="xs math"
+    version="3.0">
+
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+
+    <xsl:mode _streamable="{$STREAMABLE}"/>
+
+
+    <xsl:template match="/">
+        <out>
+            <xsl:apply-templates/>
+        </out>
+    </xsl:template>
+
+    <xsl:template match="cities">
+
+        <xsl:for-each-group select="city" group-adjacent="@name, @country" composite="yes">
+            <p>
+                <xsl:value-of select="current-grouping-key(), current-group()/@pop/xs:double(.)"
+                    separator=", "/>
+            </p>
+        </xsl:for-each-group>
+
+    </xsl:template>
+
+</xsl:stylesheet>
--- a/tests/strm/si-fork/_si-fork-test-set.xml	Wed Jul 26 13:48:12 2017 +0100
+++ b/tests/strm/si-fork/_si-fork-test-set.xml	Wed Jul 26 13:48:57 2017 +0100
@@ -586,6 +586,34 @@
       </result>
    </test-case>
    
+   <test-case name="si-fork-806">
+      <description>Aggregate (avg) computed using streamable xsl:fork containing xsl:for-each-group</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-07-13"/>
+      <environment>
+         <source role="." file="si-fork-806.xml" streaming="true"/> 
+      </environment>
+      <test>
+         <stylesheet file="si-fork-806.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Root><Brand><Vehicle>Car</Vehicle></Brand><Brand><Vehicle>Truck</Vehicle></Brand><Brand><Vehicle>Motorcycle</Vehicle></Brand></Root>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-fork-807">
+      <description>Aggregate (avg) computed using streamable xsl:fork containing xsl:for-each-group</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-07-13"/>
+      <environment>
+         <source role="." file="si-fork-806.xml" streaming="true"/> <!-- sic -->
+      </environment>
+      <test>
+         <stylesheet file="si-fork-807.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Root><Brand><Vehicle>Car</Vehicle></Brand><Brand><Vehicle>Truck</Vehicle></Brand><Brand><Vehicle>Motorcycle</Vehicle></Brand></Root>]]></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-806.xml	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cities>
+    <city name="Milano"  country="Italia"  year="1950"   pop="5.23"/>
+    <city name="Milano"  country="Italia"  year="1960"   pop="5.29"/>  
+    <city name="Padova"  country="Italia"  year="1950"   pop="0.69"/>
+    <city name="Padova"  country="Italia"  year="1960"   pop="0.93"/>    
+    <city name="Paris"   country="France"  year="1951"   pop="7.2"/>
+    <city name="Paris"   country="France"  year="1961"   pop="7.6"/>
+</cities>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-fork/si-fork-806.xsl	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,30 @@
+<?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" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+    
+    <xsl:mode _streamable="{$STREAMABLE}"/>
+    
+    <xsl:template match="/">
+            <out>
+                <xsl:apply-templates/>
+            </out>
+    </xsl:template>
+    
+    <xsl:template match="cities">
+        <xsl:fork>
+            <xsl:for-each-group select="city" 
+                group-by="@name, @country" 
+                composite="yes">
+                <p>
+                    <xsl:value-of select="current-grouping-key(), avg(current-group()/@pop)" separator=", "/>
+                </p>
+            </xsl:for-each-group>
+        </xsl:fork>
+    </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-807.xsl	Wed Jul 26 13:48:57 2017 +0100
@@ -0,0 +1,30 @@
+<?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" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+    
+    <xsl:mode _streamable="{$STREAMABLE}"/>
+    
+    <xsl:template match="/">
+        <out>
+                <xsl:apply-templates/>
+        </out>
+    </xsl:template>
+    
+    <xsl:template match="cities">
+        <xsl:fork>
+            <xsl:for-each-group select="city" 
+                group-by="@name, @country" 
+                composite="yes">
+                <p>
+                    <xsl:value-of select="current-grouping-key(), current-group()/@pop/xs:double(.)" separator=", "/>
+                </p>
+            </xsl:for-each-group>
+        </xsl:fork>
+    </xsl:template>
+    
+</xsl:stylesheet>
\ No newline at end of file