New xsl:merge/xsl:fallback test cases prompted by Saxon bug report
authorMichael Kay <mike@saxonica.com>
Mon, 28 Dec 2015 17:53:49 +0000
changeset 1194 30a6363b39ef
parent 1193 b67dcd3a540c
child 1195 db4cdc265c27
New xsl:merge/xsl:fallback test cases prompted by Saxon bug report
tests/insn/merge/_merge-test-set.xml
tests/insn/merge/merge-085.xsl
tests/insn/merge/merge-086.xsl
--- a/tests/insn/merge/_merge-test-set.xml	Mon Dec 28 17:34:22 2015 +0000
+++ b/tests/insn/merge/_merge-test-set.xml	Mon Dec 28 17:53:49 2015 +0000
@@ -1222,5 +1222,42 @@
          </all-of>   
       </result>
    </test-case>
+   
+   <test-case name="merge-085">
+      <description>xsl:merge allows xsl:fallback as last child.</description>
+      <created by="Michael Kay" on="2015-12-28"/>
+      <environment>
+         <collection uri="log-files">
+            <source file="log-files/log-file1.xml" uri="log-files/log-file1.xml"/>
+            <source file="log-files/log-file2.xml" uri="log-files/log-file2.xml"/>
+         </collection>
+      </environment>
+      <test>
+         <stylesheet file="merge-085.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<events><event timestamp="2009-08-20T12:01:01Z">Transaction T1234 started</event
+            ><event timestamp="2009-08-20T12:01:05Z">Transaction T1236 started</event
+            ><event timestamp="2009-08-20T12:01:08Z">Transaction T1235 started</event
+            ><event timestamp="2009-08-20T12:01:09Z">Transaction T1236 ended</event
+            ><event timestamp="2009-08-20T12:01:11Z">Transaction T1237 started</event
+            ><event timestamp="2009-08-20T12:01:12Z">Transaction T1235 ended</event
+            ><event timestamp="2009-08-20T12:01:15Z">Transaction T1234 ended</event
+            ><event timestamp="2009-08-20T12:01:17Z">Transaction T1237 ended</event></events>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="merge-086">
+      <description>xsl:fallback can appear only after xsl:merge-action child elements</description>
+      <created by="Michael Kay" on="2015-12-28"/>
+      <environment ref="merge001"/>
+      <test>
+         <stylesheet file="merge-086.xsl"/>
+      </test>
+      <result>
+         <error code="XTSE0010"/>
+      </result>
+   </test-case>
 
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/merge/merge-085.xsl	Mon Dec 28 17:53:49 2015 +0000
@@ -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"
+    exclude-result-prefixes="xs"
+    version="3.0">
+    <!-- xsl:merge test on a homogeneous collection of XML log files. -->
+    <xsl:output method="xml" indent="no"/>
+    
+    <xsl:template name="main">
+        <events>
+            <xsl:merge>                
+                <xsl:merge-source 
+                		for-each-item="collection('log-files')"
+                		select="events/event">
+                    <xsl:merge-key select="@timestamp"/>
+                </xsl:merge-source>
+                <xsl:merge-action>
+                    <xsl:copy-of select="current-merge-group()" />
+                </xsl:merge-action>
+                <xsl:fallback>111</xsl:fallback>
+                <xsl:fallback>222</xsl:fallback>
+            </xsl:merge>
+            
+        </events>
+    </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/merge/merge-086.xsl	Mon Dec 28 17:53:49 2015 +0000
@@ -0,0 +1,22 @@
+<?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">
+    <!-- error: xsl:fallback must follow xsl:merge-action -->
+    <xsl:template name="main">
+    <xsl:result-document href="merged-events.xml">
+        <events>
+            <xsl:merge>
+                <xsl:merge-source select="doc('log-file-1.xml')/events/event">
+                        <xsl:merge-key select="@timestamp"/>
+                </xsl:merge-source>
+                <xsl:fallback>22</xsl:fallback>
+                <xsl:merge-action>
+                    <xsl:copy-of select="current-merge-group()" />
+                </xsl:merge-action>
+            </xsl:merge>
+        </events>
+    </xsl:result-document>
+    </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file