base-uri() with external entities and xi:include
authorMichael Kay <mike@saxonica.com>
Tue, 05 Dec 2017 23:11:56 +0000
changeset 1790 008e4a6227e6
parent 1789 7fe5dce7e15e
child 1791 98e61a8aba13
base-uri() with external entities and xi:include
tests/fn/base-uri/_base-uri-test-set.xml
tests/fn/base-uri/base-uri-051.xsl
tests/fn/base-uri/baseuri051.xml
tests/fn/base-uri/baseuri052.xml
tests/fn/base-uri/dir/data.xml
tests/fn/base-uri/dir/data1.xml
tests/fn/base-uri/dir/data2.xml
--- a/tests/fn/base-uri/_base-uri-test-set.xml	Tue Dec 05 23:11:06 2017 +0000
+++ b/tests/fn/base-uri/_base-uri-test-set.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -865,4 +865,53 @@
          </all-of>
       </result>
    </test-case>
+   
+   <test-case name="base-uri-051">
+      <description>base-uri() applied to elements within an external entity.</description>
+      <created by="Michael Kay" on="2016-12-21"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+         <feature value="dtd"/>
+      </dependencies>
+      <environment>
+         <source role="." file="baseuri051.xml"/>
+      </environment>
+      <test>
+         <stylesheet file="base-uri-051.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>ends-with(/out/one, 'fn/base-uri/baseuri051.xml')</assert>
+            <assert>ends-with(/out/two, 'fn/base-uri/dir/data.xml')</assert>
+            <assert>ends-with(/out/three, 'fn/base-uri/dir/dir2/data.xml')</assert>
+            <assert>ends-with(/out/four, 'fn/base-uri/dir/data.xml')</assert>
+            <assert>ends-with(/out/five, 'fn/base-uri/dir/dir5/data.xml')</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="base-uri-052">
+      <description>base-uri() applied to elements within a document read using XInclude.</description>
+      <created by="Michael Kay" on="2016-12-21"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <environment>
+         <source role="." file="baseuri052.xml" xinclude="true"/>
+      </environment>
+      <test>
+         <stylesheet file="base-uri-051.xsl"/> <!--sic-->
+      </test>
+      <result>
+         <all-of>
+            <assert>ends-with(/out/one, 'fn/base-uri/baseuri052.xml')</assert>
+            <assert>ends-with(/out/two, 'fn/base-uri/dir/data1.xml')</assert>
+            <assert>ends-with(/out/three, 'fn/base-uri/dir/dir2/data.xml')</assert>
+            <assert>ends-with(/out/four, 'fn/base-uri/dir/data1.xml')</assert>
+            <!-- The spec says "If an xml:base attribute information item is already present, it is replaced by the new attribute"
+                 but Xerces doesn't appear to do this -->
+            <assert>ends-with(/out/five, 'fn/base-uri/dir5/data.xml')</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-051.xsl	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+             version="3.0" expand-text="yes">
+<!-- Purpose: Test base-uri applied to input nodes created using external entities.-->
+
+   <xsl:template match="/">
+      <xsl:message><xsl:copy-of select="."/></xsl:message>
+      <out>
+         <one>{base-uri(//para[.='one'])}</one>
+         <two>{base-uri(//item[.='two'])}</two>
+         <three>{base-uri(//item[.='three'])}</three>
+         <four>{base-uri(//item[.='three']/ancestor::para)}</four>
+         <five>{base-uri(//para[.='five'])}</five>
+      </out>
+   </xsl:template>
+ 
+</xsl:transform>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/baseuri051.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,11 @@
+<!DOCTYPE doc [
+<!ENTITY e SYSTEM "dir/data.xml">
+]>
+<doc>
+    <chap>
+        <para>one</para>
+    </chap>
+    <chap>
+        &e;
+    </chap>
+</doc>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/baseuri052.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,9 @@
+<doc>
+    <chap>
+        <para>one</para>
+    </chap>
+    <chap>
+        <xi:include href="dir/data1.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+        <xi:include href="dir/data2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+    </chap>
+</doc>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/dir/data.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,7 @@
+<para>
+    <list>
+        <item>two</item>
+        <item xml:base="dir2/data.xml">three</item>
+    </list>
+</para>
+<para xml:base="dir5/data.xml">five</para>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/dir/data1.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,6 @@
+<para>
+    <list>
+        <item>two</item>
+        <item xml:base="dir2/data.xml">three</item>
+    </list>
+</para>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/base-uri/dir/data2.xml	Tue Dec 05 23:11:56 2017 +0000
@@ -0,0 +1,1 @@
+<para xml:base="dir5/data.xml">five</para>
\ No newline at end of file