Add test case for xsl:iterate streaming with early exit
authorMichael Kay <mike@saxonica.com>
Mon, 02 Feb 2015 16:52:20 +0000
changeset 818 b3f51206e8f4
parent 817 21e7bcbd6b3c
child 819 ac439cebdd50
Add test case for xsl:iterate streaming with early exit
tests/strm/si-iterate/_si-iterate-test-set.xml
tests/strm/si-iterate/si-iterate-094.xml
tests/strm/si-iterate/si-iterate-094.xsl
--- a/tests/strm/si-iterate/_si-iterate-test-set.xml	Thu Jan 29 16:29:27 2015 +0000
+++ b/tests/strm/si-iterate/_si-iterate-test-set.xml	Mon Feb 02 16:52:20 2015 +0000
@@ -164,6 +164,22 @@
       </result>
    </test-case>
    
+   <test-case name="si-iterate-094">
+      <description>Streaming xsl:iterate, with possibility of early exit. (From Martin Honnen)</description>
+      <created by="Michael Kay" on="2015-02-02"/>
+      <environment>
+        <source role="." streaming="true" file="si-iterate-094.xml"/>
+      </environment>  
+      <test>
+         <stylesheet file="si-iterate-094.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert-xml><![CDATA[<out><p>foo bar foobar</p><p>foobar baz foo</p></out>]]></assert-xml>
+         </all-of>
+      </result>
+   </test-case>
+   
    <test-case name="si-iterate-095">
       <description>within a streaming template, use xsl:iterate to process the subtree</description>
       <created by="Michael Kay" on="2012-11-07"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-094.xml	Mon Feb 02 16:52:20 2015 +0000
@@ -0,0 +1,11 @@
+<doc>
+  <chapter>
+    <p>foo bar foobar</p>
+  </chapter>
+  <chapter>
+    <p>foobar baz foo</p>
+  </chapter>
+  <chapter>
+    <p>baz bar foobaz</p>
+  </chapter>
+</doc>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-094.xsl	Mon Feb 02 16:52:20 2015 +0000
@@ -0,0 +1,22 @@
+<xsl:stylesheet version="3.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  exclude-result-prefixes="xs">
+
+<xsl:mode streamable="yes"/>
+
+<xsl:template match="/">
+ <out>
+  <xsl:iterate select="doc/chapter/p">
+    <xsl:copy>
+      <xsl:copy-of select="@*"/>
+      <xsl:copy-of select="node()"/>
+    </xsl:copy>
+    <xsl:if test="position() ge 2">
+      <xsl:break/>
+    </xsl:if>
+  </xsl:iterate>
+ </out> 
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file