New tests - built-in template rules for arrays
authorMichael Kay <mike@saxonica.com>
Mon, 13 Nov 2017 14:28:29 +0000
changeset 1784 3390faae04e0
parent 1783 b0e20148f68c
child 1785 99d9c32f0fac
New tests - built-in template rules for arrays
admin/catalog-schema.xsd
tests/type/arrays/_arrays-test-set.xml
tests/type/arrays/arrays-301.xsl
tests/type/arrays/arrays-302.xsl
--- a/admin/catalog-schema.xsd	Thu Nov 02 16:14:07 2017 +0000
+++ b/admin/catalog-schema.xsd	Mon Nov 13 14:28:29 2017 +0000
@@ -1588,6 +1588,9 @@
                     tree is written. The location should be given as a relative URI, and should be
                     within a subdirectory of the directory that contains the test set XML file.</p>
                 <p>Directions for output post-processing can also be declared.</p>
+                <p>If the result-var attribute is present then the result of the transformation is
+                bound to a named variable rather than to the context item. This allows testing of
+                transformations that return a non-singleton sequence (see bug 30196).</p>
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
@@ -1595,6 +1598,7 @@
             <xs:attribute name="tree" type="yesNoType" use="optional"/>
             <xs:attribute name="serialize" type="yesNoType" use="optional"/>
             <xs:attribute name="well-formed" type="yesNoType" use="optional"/>
+            <xs:attribute name="result-var" type="xs:NCName" use="optional"/>
         </xs:complexType>
     </xs:element>
 
--- a/tests/type/arrays/_arrays-test-set.xml	Thu Nov 02 16:14:07 2017 +0000
+++ b/tests/type/arrays/_arrays-test-set.xml	Mon Nov 13 14:28:29 2017 +0000
@@ -780,5 +780,27 @@
          </all-of>
       </result>
    </test-case>
+   
+   <test-case name="arrays-301">
+      <description>Built-in template rule for arrays (text-only copy)</description>
+      <created by="Michael Kay" on="2017-11-13"/>
+      <test>
+         <stylesheet file="arrays-301.xsl"/>
+      </test>
+      <result>
+            <assert>deep-equal(/out/element/@name/string(), ("a", "b", "c", "d"))</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="arrays-302">
+      <description>Built-in template rule for arrays (shallow-skip)</description>
+      <created by="Michael Kay" on="2017-11-13"/>
+      <test>
+         <stylesheet file="arrays-302.xsl"/>
+      </test>
+      <result>
+         <assert>deep-equal(/out/element/@name/string(), ("a", "b", "c", "d"))</assert>
+      </result>
+   </test-case>
 
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/type/arrays/arrays-301.xsl	Mon Nov 13 14:28:29 2017 +0000
@@ -0,0 +1,26 @@
+<xsl:stylesheet version="3.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="map xs">
+    
+   <xsl:variable name="data" as="element()*">
+     <a>1</a>
+     <b>2</b>
+     <c>3</c>
+     <d>4</d>
+   </xsl:variable>
+ 
+ 
+  <xsl:template name="xsl:initial-template">
+    <out>
+      <xsl:apply-templates select="array{$data}"/>
+    </out>
+  </xsl:template>
+  
+  <xsl:template match="*">
+    <element name="{name()}"/>
+  </xsl:template>
+            
+    
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/type/arrays/arrays-302.xsl	Mon Nov 13 14:28:29 2017 +0000
@@ -0,0 +1,28 @@
+<xsl:stylesheet version="3.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="map xs">
+    
+   <xsl:variable name="data" as="element()*">
+     <a>1</a>
+     <b>2</b>
+     <c>3</c>
+     <d>4</d>
+   </xsl:variable>
+  
+  <xsl:mode on-no-match="shallow-skip"/>
+ 
+ 
+  <xsl:template name="xsl:initial-template">
+    <out>
+      <xsl:apply-templates select="array{$data}"/>
+    </out>
+  </xsl:template>
+  
+  <xsl:template match="*">
+    <element name="{name()}"/>
+  </xsl:template>
+            
+    
+</xsl:stylesheet>
\ No newline at end of file