Additional xsl:iterate test case in response to Saxon bug
authorMichael Kay <mike@saxonica.com>
Mon, 28 Dec 2015 17:34:22 +0000
changeset 1193 b67dcd3a540c
parent 1192 bee08af8dd04
child 1194 30a6363b39ef
Additional xsl:iterate test case in response to Saxon bug
tests/insn/iterate/_iterate-test-set.xml
tests/insn/iterate/iterate-034.xsl
--- a/tests/insn/iterate/_iterate-test-set.xml	Tue Dec 22 10:23:37 2015 +0000
+++ b/tests/insn/iterate/_iterate-test-set.xml	Mon Dec 28 17:34:22 2015 +0000
@@ -495,6 +495,19 @@
       </result>
    </test-case>
    
+   <test-case name="iterate-034">
+      <description>Nested xsl:iterate instructions</description>
+      <created by="Michael Kay" on="2015-12-28"/>
+      <test>
+         <stylesheet file="iterate-034.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><day date="2015-01-01" days.left="5"/><day date="2015-01-02" days.left="4"
+            /><day date="2015-01-03" days.left="3"/><day date="2015-01-04" days.left="2"
+            /><day date="2015-01-05" days.left="1"/><day date="2015-01-06" days.left="0"/></out>]]></assert-xml>
+      </result>
+   </test-case>  
+   
    <test-case name="iterate-901">
       <description>Basic Test of xsl:iterate instruction. Error, xsl:param must come first</description>
       <created by="Michael Kay" on="2012-11-07"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/iterate/iterate-034.xsl	Mon Dec 28 17:34:22 2015 +0000
@@ -0,0 +1,33 @@
+<?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" exclude-result-prefixes="xs" version="3.0">
+
+	<xsl:variable name="data">
+		<row Date="2015-01-01"/>
+		<row Date="2015-01-02"/>
+		<row Date="2015-01-03"/>
+		<row Date="2015-01-04"/>
+		<row Date="2015-01-05"/>
+		<row Date="2015-01-06"/>
+	</xsl:variable>
+
+	<xsl:template name="xsl:initial-template">
+		<out>
+			<xsl:iterate select="$data//row">
+				<xsl:variable name="days.left" as="xs:integer">
+					<xsl:iterate select="following-sibling::row">
+						<xsl:param name="days" select="0"/>
+						<xsl:on-completion>
+							<xsl:sequence select="$days"/>
+						</xsl:on-completion>
+						<xsl:next-iteration>
+							<xsl:with-param name="days" select="$days + 1"/>
+						</xsl:next-iteration>
+					</xsl:iterate>
+				</xsl:variable>
+				<day date="{@Date}" days.left="{$days.left}"/>
+			</xsl:iterate>
+		</out>
+	</xsl:template>
+
+</xsl:stylesheet>