Two streaming tests of xsl:iterate, from a Saxon bug report
authorMichael Kay <mike@saxonica.com>
Tue, 05 Aug 2014 18:11:28 +0100
changeset 589 027ab344cfa4
parent 588 abe02b4a9456
child 590 3d243483f707
child 598 1bc3bddb8e5b
Two streaming tests of xsl:iterate, from a Saxon bug report
tests/strm/si-iterate/_si-iterate-test-set.xml
tests/strm/si-iterate/si-iterate-134.xsl
tests/strm/si-iterate/si-iterate-135.xsl
--- a/tests/strm/si-iterate/_si-iterate-test-set.xml	Sun Aug 03 20:10:19 2014 +0100
+++ b/tests/strm/si-iterate/_si-iterate-test-set.xml	Tue Aug 05 18:11:28 2014 +0100
@@ -272,6 +272,32 @@
          <assert-xml><![CDATA[<result><polygons>2849</polygons><points>4070</points></result>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="si-iterate-134">
+      <description>streaming xsl:iterate with maps. From Saxon bug 2006.</description>
+      <created by="John Lumley" on="2014-08-05"/>
+      <environment ref="citygml"/>
+      <test>
+         <stylesheet file="si-iterate-134.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<tba/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-iterate-135">
+      <description>streaming xsl:iterate with maps, sorting a grounded sequence. From Saxon bug 2006.</description>
+      <created by="John Lumley" on="2014-08-05"/>
+      <environment ref="citygml"/>
+      <test>
+         <stylesheet file="si-iterate-135.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<tba/>]]></assert-xml>
+      </result>
+   </test-case>
 
    <test-case name="si-iterate-806">
       <description>Use xsl:iterate within xsl:stream, //a/b is not guaranteed streamable in the spec, but streamable in Saxon</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-134.xsl	Tue Aug 05 18:11:28 2014 +0100
@@ -0,0 +1,26 @@
+<?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:map="http://www.w3.org/2005/xpath-functions/map"
+  exclude-result-prefixes="xs" version="3.0">
+  <xsl:template name="main">
+    <xsl:stream href="../docs/citygml.xml">
+      <elements>
+        <xsl:variable name="histogram" as="map(xs:string, xs:integer)">
+          <xsl:iterate select=".//*/name()">
+            <xsl:param name="m" as="map(xs:string, xs:integer)" select="map{}"/>
+            <xsl:on-completion>
+              <xsl:sequence select="$m"/>
+            </xsl:on-completion>
+            <xsl:variable name="count" as="xs:integer?" select="($m(.), 0)[1]"/>
+            <xsl:next-iteration>
+              <xsl:with-param name="m" select="map:new(($m, map:entry(., $count+1)))"/>
+            </xsl:next-iteration>           
+          </xsl:iterate>
+        </xsl:variable>
+        <xsl:for-each select="map:keys($histogram)">
+          <e name="{.}" count="$histogram(.)"/>
+        </xsl:for-each>
+      </elements>
+    </xsl:stream>
+  </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-135.xsl	Tue Aug 05 18:11:28 2014 +0100
@@ -0,0 +1,27 @@
+<?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:map="http://www.w3.org/2005/xpath-functions/map"
+  exclude-result-prefixes="xs" version="3.0">
+  <xsl:template name="main">
+    <xsl:stream href="../docs/citygml.xml">
+      <elements>
+        <xsl:variable name="histogram" as="map(xs:string, xs:integer)">
+          <xsl:iterate select=".//*/name()">
+            <xsl:param name="m" as="map(xs:string, xs:integer)" select="map{}"/>
+            <xsl:on-completion>
+              <xsl:sequence select="$m"/>
+            </xsl:on-completion>
+            <xsl:variable name="count" as="xs:integer?" select="($m(.), 0)[1]"/>
+            <xsl:next-iteration>
+              <xsl:with-param name="m" select="map:new(($m, map:entry(., $count+1)))"/>
+            </xsl:next-iteration>           
+          </xsl:iterate>
+        </xsl:variable>
+        <xsl:for-each select="map:keys($histogram)">
+          <xsl:sort select="."/>
+          <e name="{.}" count="$histogram(.)"/>
+        </xsl:for-each>
+      </elements>
+    </xsl:stream>
+  </xsl:template>
+</xsl:stylesheet>