Test integrity of tree resulting from deep copy
authorMichael Kay <mike@saxonica.com>
Mon, 18 Sep 2017 23:28:14 +0100
changeset 1756 77b6da0b5d67
parent 1755 734cb9e04b55
child 1757 42a8d79bce60
Test integrity of tree resulting from deep copy
tests/insn/copy/_copy-test-set.xml
tests/insn/copy/copy-3802.xsl
tests/insn/copy/copy-3803.xsl
--- a/tests/insn/copy/_copy-test-set.xml	Mon Sep 18 23:27:28 2017 +0100
+++ b/tests/insn/copy/_copy-test-set.xml	Mon Sep 18 23:28:14 2017 +0100
@@ -1655,6 +1655,44 @@
          <assert-xml><![CDATA[<out attr1="Hello&#xA;        Success&#xA;        &#xA;      More"/>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="copy-3802">
+      <description>Test deep-equal on the result of a copy including comments, namespaces, etc</description>
+      <created by="Michael Kay" on="2017-09-15"/>
+      <environment ref="copy-38"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-3802.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/a = "true"</assert>
+            <assert>/out/b = "true"</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-3803">
+      <description>Test parent and sibling axes work after deep copy</description>
+      <created by="Michael Kay" on="2017-09-15"/>
+      <environment ref="copy-38"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-3803.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/a = "true"</assert>
+            <assert>/out/b = "true"</assert>
+            <assert>/out/c = "true"</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
 
    <test-case name="copy-3901">
       <description>FileName: copy57 Document: http://www.w3.org/TR/xslt DocVersion: 19991116
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-3802.xsl	Mon Sep 18 23:28:14 2017 +0100
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<!-- Test deep-equal on the result of a copy including comments, whitespace, etc -->
+
+<xsl:output method="xml" indent="no" encoding="UTF-8"/>
+  
+  <xsl:variable name="deep-equal" static="yes" xmlns:saxon="http://saxon.sf.net/"
+    select="if (function-available('saxon:deep-equal', 4)) then saxon:deep-equal(?, ?, (), '?') else deep-equal#2"/>
+
+<xsl:template match="/">
+  <xsl:variable name="temp">
+    <z1>
+      <z2>
+        <z3>
+          <xsl:copy-of select="."/>
+        </z3>
+        <z4>
+          <xsl:copy-of select="./*"/>
+        </z4>
+      </z2>
+    </z1>
+  </xsl:variable>
+  <out>
+    <z><xsl:copy-of select="$temp"/></z>
+    <a><xsl:value-of select="$deep-equal($temp//z3/*, ./*)"/></a>
+    <b><xsl:value-of select="$deep-equal($temp//z4/*, ./*)"/></b>
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-3803.xsl	Mon Sep 18 23:28:14 2017 +0100
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<!-- Test siblings and parent axes work after deep copy -->
+
+<xsl:output method="xml" indent="no" encoding="UTF-8"/>
+  
+  <xsl:variable name="deep-equal" static="yes" xmlns:saxon="http://saxon.sf.net/"
+    select="if (function-available('saxon:deep-equal', 4)) then saxon:deep-equal(?, ?, (), '?') else deep-equal#2"/>
+
+<xsl:template match="/">
+  <xsl:variable name="temp">
+    <z1>
+      <z2>
+        <z3/>
+        <xsl:copy-of select="."/>
+        <z4/>
+        <xsl:copy-of select="./*"/>
+      </z2>
+    </z1>
+  </xsl:variable>
+  <out>
+    <z><xsl:value-of select="$temp//z3/following-sibling::node()/('['||local-name(.)||']')"/></z>
+    <a><xsl:value-of select="deep-equal($temp//z3/following-sibling::node()/local-name(.), ('docs', 'z4', 'docs')) "/></a>
+    <b><xsl:value-of select="every $n in $temp//z2/node() satisfies $n/parent::* is $temp//z2"/></b>
+    <c><xsl:value-of select="deep-equal($temp//z2/node()[last()]!reverse(preceding-sibling::node()/local-name(.)), ('z4', 'docs', 'z3'))"/></c>
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file