Add a couple of for-each streaming tests
authorMichael Kay <mike@saxonica.com>
Fri, 10 Jul 2015 10:07:42 +0100
changeset 1017 69b2e75c9ba5
parent 1016 e6dbb71e09d2
child 1018 9319bed7bead
Add a couple of for-each streaming tests
tests/strm/si-for-each/_si-for-each-test-set.xml
tests/strm/si-for-each/si-for-each-A.xsl
--- a/tests/strm/si-for-each/_si-for-each-test-set.xml	Fri Jul 10 00:00:37 2015 +0100
+++ b/tests/strm/si-for-each/_si-for-each-test-set.xml	Fri Jul 10 10:07:42 2015 +0100
@@ -97,6 +97,21 @@
       </result>
    </test-case>
    
+   <test-case name="si-for-each-007">
+      <description>xsl:stream / xsl:for-each / xsl:copy-of with a predicate</description>
+      <created by="Michael Kay" on="2015-07-10"/>
+      <environment ref="si-for-each-A"/>
+      <test>
+         <initial-template name="fe-007"/>
+      </test>
+      <result>
+        <assert-xml><![CDATA[<out><TITLE>Pride and Prejudice</TITLE><AUTHOR>Jane Austen</AUTHOR
+        ><PUBLISHER>Modern Library</PUBLISHER><PUB-DATE>2002-12-31</PUB-DATE><LANGUAGE>English</LANGUAGE
+        ><PRICE>4.95</PRICE><QUANTITY>187</QUANTITY><ISBN>0679601686</ISBN><PAGES>352</PAGES
+        ><DIMENSIONS UNIT="in">8.3 5.7 1.1</DIMENSIONS><WEIGHT UNIT="oz">6.1</WEIGHT></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
    <test-case name="si-for-each-008">
       <description>Use parent axis within xsl:for-each</description>
       <created by="Michael Kay" on="2013-11-28"/>
@@ -161,6 +176,21 @@
       </result>
    </test-case>
    
+   <test-case name="si-for-each-013">
+      <description>xsl:stream / xsl:for-each / xsl:copy-of with a predicate and some local variables</description>
+      <created by="Michael Kay" on="2015-07-10"/>
+      <environment ref="si-for-each-A"/>
+      <test>
+         <initial-template name="fe-013"/>
+      </test>
+      <result>
+        <assert-xml><![CDATA[<out><TITLE>Pride and Prejudice</TITLE><AUTHOR>Jane Austen</AUTHOR
+        ><PUBLISHER>Modern Library</PUBLISHER><PUB-DATE>2002-12-31</PUB-DATE><LANGUAGE>English</LANGUAGE
+        ><PRICE>4.95</PRICE><QUANTITY>187</QUANTITY><ISBN>0679601686</ISBN><PAGES>352</PAGES
+        ><DIMENSIONS UNIT="in">8.3 5.7 1.1</DIMENSIONS><WEIGHT UNIT="oz">6.1</WEIGHT></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
    <test-case name="si-for-each-801">
       <description>Use streaming xsl:for-each referring to a global variable (Saxon bug 2412)</description>
       <created by="Michael Kay" on="2015-07-04"/>
--- a/tests/strm/si-for-each/si-for-each-A.xsl	Fri Jul 10 00:00:37 2015 +0100
+++ b/tests/strm/si-for-each/si-for-each-A.xsl	Fri Jul 10 10:07:42 2015 +0100
@@ -83,6 +83,18 @@
     </out>
   </xsl:template>
   
+  <!-- xsl:stream / xsl:for-each / xsl:copy-of with a predicate -->
+  
+  <xsl:template name="fe-007">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="*[namespace-uri(.) = '']"/>
+          </xsl:for-each>  
+        </out>
+      </xsl:stream>
+  </xsl:template>
+  
   <!-- within xsl:stream, use parent axis within xsl:for-each -->
    
   <xsl:template name="fe-008">
@@ -147,6 +159,19 @@
         </xsl:for-each>
       </xsl:stream>
     </out>
+  </xsl:template>
+  
+  <!-- xsl:stream / xsl:for-each / xsl:copy-of with a predicate and some local variables-->
+  
+  <xsl:template name="fe-013">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:variable name="x" select="current-date()"/>
+            <xsl:copy-of select="let $y := current-dateTime() return *[namespace-uri(.) != string($x) and local-name(.) != string($y) and name(.) != concat($x, $y)]"/>
+          </xsl:for-each>  
+        </out>
+      </xsl:stream>
   </xsl:template>