New xsl:iterate test case prompted by a Saxon bug
authorMichael Kay <mike@saxonica.com>
Wed, 30 Dec 2015 13:04:42 +0000
changeset 1197 d300f98a5bb8
parent 1196 1d6926487cf1
child 1198 aacf3d6d8681
New xsl:iterate test case prompted by a Saxon bug
tests/strm/si-iterate/_si-iterate-test-set.xml
tests/strm/si-iterate/si-iterate-013.xml
tests/strm/si-iterate/si-iterate-013.xsl
--- a/tests/strm/si-iterate/_si-iterate-test-set.xml	Mon Dec 28 17:55:56 2015 +0000
+++ b/tests/strm/si-iterate/_si-iterate-test-set.xml	Wed Dec 30 13:04:42 2015 +0000
@@ -165,6 +165,21 @@
       </result>
    </test-case>
    
+   <test-case name="si-iterate-013">
+      <description>Streaming xsl:iterate using xsl:break</description>
+      <created by="Michael Kay" on="2015-12-28"/>
+      <environment>
+         <source role="." file="si-iterate-013.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="si-iterate-013.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<root><header>...</header><item name="1">...</item><item name="2"
+            >...</item><item name="3">...</item><item name="4">...</item></root>]]></assert-xml>
+      </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"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-013.xml	Wed Dec 30 13:04:42 2015 +0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+    <header>...</header>
+    <item name="1">...</item>
+    <item name="2">...</item>
+    <item name="3">...</item>
+    <item name="4">...</item>
+    <item name="5">...</item>
+    <item name="6">...</item>
+    <item name="7">...</item>
+</root>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-iterate/si-iterate-013.xsl	Wed Dec 30 13:04:42 2015 +0000
@@ -0,0 +1,26 @@
+<xsl:stylesheet
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	version="3.0" 
+	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+	exclude-result-prefixes="xs">
+	
+	<xsl:param name="elements-to-copy" as="xs:integer" select="5"/>
+	
+	<xsl:mode streamable="yes"/>
+	
+	<xsl:output indent="yes"/>
+	
+	<xsl:global-context-item streamable="yes"/>
+	
+	<xsl:template match="/*">
+		<xsl:copy>
+			<xsl:iterate select="*">
+				<xsl:copy-of select="."/>
+				<xsl:if test="position() eq $elements-to-copy">
+					<xsl:break/>
+				</xsl:if>
+			</xsl:iterate>
+		</xsl:copy>
+	</xsl:template>
+	
+</xsl:stylesheet>
\ No newline at end of file