Add tests for base-uri of nodes constructed using built-in template rules
authorMichael Kay <mike@saxonica.com>
Sat, 02 Feb 2019 20:27:12 +0000
changeset 1957 b0fda4892e01
parent 1956 4624e4c75d67
child 1958 01b2d296e64f
Add tests for base-uri of nodes constructed using built-in template rules
tests/fn/base-uri/_base-uri-test-set.xml
tests/fn/base-uri/base-uri-053.xsl
--- a/tests/fn/base-uri/_base-uri-test-set.xml	Sat Feb 02 20:26:39 2019 +0000
+++ b/tests/fn/base-uri/_base-uri-test-set.xml	Sat Feb 02 20:27:12 2019 +0000
@@ -959,4 +959,21 @@
          </all-of>
       </result>
    </test-case>
+   
+   <test-case name="base-uri-053">
+      <description>Base URI of nodes constructed using built-in templates (shallow-copy and deep-copy). Saxon bug 4097.</description>
+      <created by="Michael Kay" on="2019-01-16"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="base-uri-053.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>every $a in /out/*/@a satisfies ends-with($a, 'base-uri/base-uri-001.out')</assert>
+            <assert>every $b in /out/*/@b satisfies ends-with($b, 'base-uri/base-uri-002.out')</assert>
+         </all-of>
+      </result>
+   </test-case>
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/base-uri-053.xsl	Sat Feb 02 20:27:12 2019 +0000
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                exclude-result-prefixes="xs"
+                version="3.0">
+<!-- Purpose: test base URI of nodes constructed using built-in template rules -->
+
+   <xsl:variable name="doc1" select="doc('base-uri-001.out')"/>
+   <xsl:variable name="doc2" select="doc('base-uri-002.out')"/>
+   
+   <xsl:template name="xsl:initial-template">
+      <out>
+         <initial-doc a="{base-uri($doc1)}" b="{base-uri($doc2)}"/>
+         <initial-elem a="{base-uri($doc1/*)}" b="{base-uri($doc2/*)}"/>
+         
+         <xsl:variable name="shallow-copy-docs" as="item()*">
+            <xsl:copy select="$doc1"><z/></xsl:copy>
+            <xsl:copy select="$doc2"><z/></xsl:copy>
+         </xsl:variable>
+         <xsl:variable name="shallow-copy-elements" as="item()*">
+            <xsl:copy select="$doc1/*"><z/></xsl:copy>
+            <xsl:copy select="$doc2/*"><z/></xsl:copy>
+         </xsl:variable>
+         <shallow-doc a="{base-uri($shallow-copy-docs[1])}" b="{base-uri($shallow-copy-docs[2])}"/>
+         <shallow-elem a="{base-uri($shallow-copy-elements[1])}" b="{base-uri($shallow-copy-elements[2])}"/>
+         <shallow-doc-deeper a="{base-uri($shallow-copy-docs[1]/z)}" b="{base-uri($shallow-copy-docs[2]/z)}"/>
+         <shallow-elem-deeper a="{base-uri($shallow-copy-elements[1]/z)}" b="{base-uri($shallow-copy-elements[2]/z)}"/>
+         
+         <xsl:variable name="deep-copy-docs" as="item()*">
+            <xsl:copy-of select="$doc1"/>
+            <xsl:copy-of select="$doc2"/>
+         </xsl:variable>
+         <xsl:variable name="deep-copy-elements" as="item()*">
+            <xsl:copy select="$doc1/*"/>
+            <xsl:copy select="$doc2/*"/>
+         </xsl:variable>
+         <deep-doc a="{base-uri($deep-copy-docs[1])}" b="{base-uri($deep-copy-docs[2])}"/>
+         <deep-elem a="{base-uri($deep-copy-elements[1])}" b="{base-uri($deep-copy-elements[2])}"/>
+         
+         <xsl:variable name="shallow-copy-docs2" as="item()*">
+            <xsl:apply-templates select="$doc1" mode="shallow-doc"/>
+            <xsl:apply-templates select="$doc2" mode="shallow-doc"/>
+         </xsl:variable>
+         <xsl:variable name="shallow-copy-elements2" as="item()*">
+            <xsl:apply-templates select="$doc1/*" mode="shallow-elem"/>
+            <xsl:apply-templates select="$doc2/*" mode="shallow-elem"/>
+         </xsl:variable>
+         <shallow-copy-doc2 a="{base-uri($shallow-copy-docs2[1])}" b="{base-uri($shallow-copy-docs2[2])}"/>
+         <shallow-copy-elem2 a="{base-uri($shallow-copy-elements2[1])}" b="{base-uri($shallow-copy-elements2[2])}"/>
+         
+         <xsl:variable name="deep-copy-docs2" as="item()*">
+            <xsl:apply-templates select="$doc1" mode="deep"/>
+            <xsl:apply-templates select="$doc2" mode="deep"/>
+         </xsl:variable>
+         <xsl:variable name="deep-copy-elements2" as="item()*">
+            <xsl:apply-templates select="$doc1/*" mode="deep"/>
+            <xsl:apply-templates select="$doc2/*" mode="deep"/>
+         </xsl:variable>
+         <deep-copy-doc2 a="{base-uri($deep-copy-docs2[1])}" b="{base-uri($deep-copy-docs2[2])}"/>
+         <deep-copy-elem2 a="{base-uri($deep-copy-elements2[1])}" b="{base-uri($deep-copy-elements2[2])}"/>
+
+      </out>
+   </xsl:template>
+   
+   <xsl:mode name="shallow-doc" on-no-match="shallow-copy"/>
+   <xsl:template match="/*" mode="shallow-doc"/>
+   
+   <xsl:mode name="shallow-elem" on-no-match="shallow-copy"/>
+   <xsl:template match="*/*" mode="shallow-elem"/>
+     
+   <xsl:mode name="deep" on-no-match="deep-copy"/>
+
+</xsl:transform>