New test case copy-3702 (Saxon bug report)
authorMichael Kay <mike@saxonica.com>
Fri, 08 Aug 2014 12:25:05 +0100
changeset 591 9e5ff3068934
parent 590 3d243483f707
child 592 8709b14f60a1
New test case copy-3702 (Saxon bug report)
tests/insn/copy/_copy-test-set.xml
tests/insn/copy/copy-3702.xsl
--- a/tests/insn/copy/_copy-test-set.xml	Fri Aug 08 12:23:59 2014 +0100
+++ b/tests/insn/copy/_copy-test-set.xml	Fri Aug 08 12:25:05 2014 +0100
@@ -1393,6 +1393,28 @@
          <assert-xml file="copy-3701.out"/>
       </result>
    </test-case>
+   
+   <test-case name="copy-3702">
+      <description>Test that in-scope namespaces are copied (Saxon bug repro)</description>
+      <created by="Michael Kay" on="2014-08-05"/>
+      <environment ref="copy-37"/>
+      <dependencies>
+         <spec value="XSLT10+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-3702.xsl"/>
+      </test>
+      <result>
+         <!--xml||tns|ns1|ns2-->
+         <all-of>
+           <assert>tokenize(/*, '\|') = 'xml'</assert>
+           <assert>tokenize(/*, '\|') = ''</assert>
+           <assert>tokenize(/*, '\|') = 'tns'</assert>
+           <assert>tokenize(/*, '\|') = 'ns1'</assert>
+           <assert>tokenize(/*, '\|') = 'ns2'</assert>
+         </all-of>
+      </result>
+   </test-case>
 
    <test-case name="copy-3801">
       <description>FileName: copy56 Document: http://www.w3.org/TR/xslt DocVersion: 19991116 AdditionalSpec: http://www.w3.org/1999/11/REC-xslt-19991116-errata/#E27</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-3702.xsl	Fri Aug 08 12:25:05 2014 +0100
@@ -0,0 +1,25 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns:f="http://www.w3.org/2005/Atom"
+               xmlns:xs="http://www.w3.org/2001/XMLSchema"
+               version="2.0">
+
+   <!-- This stylesheet is a repro of Saxon bug 2123. It is designed to check
+     that the in-scope namespaces of a copied node are correct. The particular
+     use of a pseudo-recursive function to create the copy is designed to take
+     Saxon down a particular path where the copy is a virtual copy of the original
+     node rather than a physical copy -->
+
+   <xsl:template match="/">
+      <p><xsl:value-of select="f:firstType(.,1)/in-scope-prefixes(.)" separator="|"/></p>
+   </xsl:template>
+   
+   <xsl:function name="f:firstType">
+     <xsl:param name="doc" as="node()"/>
+     <xsl:param name="which" as="xs:integer"/>
+     <xsl:copy-of select="($doc/*/*)[$which]"/>
+     <xsl:if test="$which lt 100">
+       <xsl:sequence select="f:firstType($doc, 120)"/>
+     </xsl:if>  
+   </xsl:function>
+
+</xsl:stylesheet>
\ No newline at end of file