Revised tests for copying accumulator values, see bug 30152
authorMichael Kay <mike@saxonica.com>
Wed, 19 Jul 2017 17:31:15 +0100
changeset 1725 e90178818455
parent 1724 1e1a7646a90e
child 1726 460fc782568d
Revised tests for copying accumulator values, see bug 30152
tests/decl/accumulator/_accumulator-test-set.xml
tests/decl/accumulator/accumulator-063.xsl
tests/decl/accumulator/accumulator-064.xsl
tests/decl/accumulator/accumulator-065.xsl
tests/decl/accumulator/accumulator-066.xsl
tests/decl/accumulator/accumulator-067.xsl
tests/decl/accumulator/accumulator-069.xsl
tests/decl/accumulator/accumulator-070.xsl
--- a/tests/decl/accumulator/_accumulator-test-set.xml	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/_accumulator-test-set.xml	Wed Jul 19 17:31:15 2017 +0100
@@ -1473,6 +1473,23 @@
             ></TRANSACTION-LIST>]]></assert-xml>        
       </result>
    </test-case>
+   
+   <test-case name="accumulator-070">
+      <description>xsl:copy-of combining copy-accumulators=yes with validation=strict</description>
+      <created by="Michael Kay" on="2017-07-19"/>
+      <dependencies>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <stylesheet file="accumulator-070.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/doc/b-acc='3'</assert>
+            <assert>/doc/c-acc='4'</assert>
+         </all-of>           
+      </result>
+   </test-case>
  
  
 </test-set>
\ No newline at end of file
--- a/tests/decl/accumulator/accumulator-063.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-063.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -19,10 +19,10 @@
   <xsl:mode on-no-match="shallow-copy"/>
   
   <xsl:template match="b">
-    <xsl:variable name="x">
+    <xsl:variable name="x" as="element()">
       <xsl:copy-of select="." copy-accumulators="yes"/>
     </xsl:variable>
-    <xsl:for-each select="$x/*">
+    <xsl:for-each select="$x">
       <b-acc>{accumulator-before('f:elementNr')}</b-acc>
     </xsl:for-each>
   </xsl:template>
--- a/tests/decl/accumulator/accumulator-064.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-064.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -19,10 +19,10 @@
   <xsl:mode on-no-match="shallow-copy"/>
   
   <xsl:template match="b">
-    <xsl:variable name="x">
+    <xsl:variable name="x" as="element()">
       <xsl:sequence select="copy-of(.)"/>
     </xsl:variable>
-    <xsl:for-each select="$x/*">
+    <xsl:for-each select="$x">
       <b-acc>{accumulator-before('f:elementNr')}</b-acc>
     </xsl:for-each>
   </xsl:template>
--- a/tests/decl/accumulator/accumulator-065.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-065.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -21,10 +21,10 @@
   <xsl:mode on-no-match="shallow-copy"/>
   
   <xsl:template match="b">
-    <xsl:variable name="x">
+    <xsl:variable name="x" as="element()">
       <xsl:sequence select="$copyFn(.)"/>
     </xsl:variable>
-    <xsl:for-each select="$x/*">
+    <xsl:for-each select="$x">
       <b-acc>{accumulator-before('f:elementNr')}</b-acc>
     </xsl:for-each>
   </xsl:template>
--- a/tests/decl/accumulator/accumulator-066.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-066.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -21,10 +21,10 @@
   <xsl:mode on-no-match="shallow-copy"/>
   
   <xsl:template match="b">
-    <xsl:variable name="x">
+    <xsl:variable name="x" as="element()">
       <xsl:sequence select="snapshot(.)"/>
     </xsl:variable>
-    <xsl:for-each select="$x/*">
+    <xsl:for-each select="$x">
       <b-acc>{accumulator-before('f:elementNr')}</b-acc>
     </xsl:for-each>
   </xsl:template>
--- a/tests/decl/accumulator/accumulator-067.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-067.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -21,10 +21,10 @@
   <xsl:mode on-no-match="shallow-copy"/>
   
   <xsl:template match="b">
-    <xsl:variable name="x">
+    <xsl:variable name="x" as="element()">
       <xsl:sequence select="$snapshotFn(.)"/>
     </xsl:variable>
-    <xsl:for-each select="$x/*">
+    <xsl:for-each select="$x">
       <b-acc>{accumulator-before('f:elementNr')}</b-acc>
     </xsl:for-each>
   </xsl:template>
--- a/tests/decl/accumulator/accumulator-069.xsl	Tue Jul 18 22:27:09 2017 +0100
+++ b/tests/decl/accumulator/accumulator-069.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -11,8 +11,6 @@
     
     <xsl:mode _streamable="{$STREAMABLE}" on-no-match="shallow-skip" use-accumulators="item1-count subitem groups"/>
     
-    <xsl:output indent="yes"/>
-    
     <xsl:accumulator name="item1-count" as="xs:integer" initial-value="0" _streamable="{$STREAMABLE}">
         <xsl:accumulator-rule match="TRANSACTION" select="0"/>
         <xsl:accumulator-rule match="TRANSACTION/ITEM1" select="$value + 1"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/decl/accumulator/accumulator-070.xsl	Wed Jul 19 17:31:15 2017 +0100
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:f="http://accum001/"
+  exclude-result-prefixes="xs f" version="3.0"  declared-modes="no" expand-text="yes">
+
+  <!-- Test xsl:copy-of using copy-accumulators=true and validation=strict -->
+ 
+  <xsl:import-schema>
+    <xs:schema>
+      <xs:element name="b">
+        <xs:complexType>
+          <xs:sequence/>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </xsl:import-schema>
+
+  <xsl:variable name="data">
+    <doc><a/><b/><c/></doc>
+  </xsl:variable>
+
+  <xsl:accumulator name="f:elementNr" as="xs:integer" initial-value="0"
+       streamable="false">
+    <xsl:accumulator-rule match="*" select="$value + 1"/>
+  </xsl:accumulator>
+  
+  <xsl:mode on-no-match="shallow-copy"/>
+  
+  <xsl:template match="b">
+    <xsl:variable name="x" as="element()">
+      <xsl:copy-of select="." copy-accumulators="yes" validation="strict"/>
+    </xsl:variable>
+    <xsl:for-each select="$x">
+      <b-acc>{accumulator-before('f:elementNr')}</b-acc>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template match="c">
+    <c-acc>{accumulator-before('f:elementNr')}</c-acc>
+  </xsl:template>
+  
+  <xsl:template name="xsl:initial-template">
+    <xsl:apply-templates select="$data"/>
+  </xsl:template>
+
+</xsl:package>