Project

Profile

Help

Bug #4281

closed

Further problems with base URI and xi:include

Added by Michael Kay over 4 years ago. Updated over 4 years ago.

Status:
Won't fix
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2019-08-14
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

This was raised as a continuation of bug #3530 but I'm transferring it to a new thread.

Hi,

I have now a similar issue with nested XIncludes using Saxon-HE-9.9.1-4.jar (from commandline).

root.xml:

<root xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="subfolder/child.xml"/>
</root>

subfolder/child.xml:

<child xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="otherchild.xml"/>
</child>

subfolder/otherchild.xml:

<otherchild/>

xsl: same as Patrick's.

Output:

root: file:/[...]/root.xml
child: file:/[...]/subfolder/child.xml
otherchild: file:/[...]/subfolder/subfolder/otherchild.xml

I tested also with Saxon-HE-9.8.0-12.jar on commandline with the same result.

Calling the HE-9.8.0-12 inside of Oxygen 20.1 I get:

root: file:/[...]/root.xml
child: file:/[...]/subfolder/subfolder/child.xml
otherchild: file:/[...]/subfolder/otherchild.xml

Strange...

Thanks & Best Regards,

Nico

Actions #1

Updated by Michael Kay over 4 years ago

The XML parser (Xerces from Apache) is presenting Saxon with a tree as follows:

<root xmlns:xi="...">
   <child xml:base="subfolder/child.xml">
      <otherchild xml:base="subfolder/otherchild.xml"/>
   </child>
</root>

The XML Base specification (ยง4.3) says: The base URI for a URI reference appearing in an xml:base attribute is the base URI of the parent element of the element bearing the xml:base attribute, if one exists within the document entity or external entity, otherwise the base URI of the document entity or external entity containing the element.

So the base URI for resolving otherchild/@xmlbase is the base URI of child, which is subfolder/child.xml, and this makes the base URI of the otherchild element subfolder/subfolder/otherchild.xml.

I believe that Apache Xerces is getting this wrong, and I don't think there's very much that Saxon can do about it (other than, in extremis, substituting our own implementation of XInclude for the one in Xerces).

The built-in version of Xerces in the Java 8 JDK gives the same result.

I can't comment on the oXygen result. Perhaps they are using their own XInclude processor rather than the Xerces one.

Actions #2

Updated by Michael Kay over 4 years ago

Perhaps we need to read the spec more carefully:

The base URI for a URI reference appearing in an xml:base attribute is the base URI of the parent element of the element bearing the xml:base attribute, if one exists within the document entity or external entity, otherwise the base URI of the document entity or external entity containing the element.

Now "the element bearing the xml:base attribute" isn't actually in any entity, because it's constructed on-the-fly by the XInclude processor, but perhaps this is referring to the original element before it acquired the xml:base attribute, in which case the parent of otherchild is not in the sane entity as child, and therefore perhaps the "otherwise" clause should apply. But the base URI of the entity containing the (original) otherchild element is xxx/subfolder/otherchild.xml, so we still get the same problem.

I'm going to throw this one at the experts on xml-dev.

Actions #3

Updated by Jirka Kosek over 4 years ago

I believe that you are facing the following bug:

https://issues.apache.org/jira/browse/XERCESJ-1102

Actions #4

Updated by Michael Kay over 4 years ago

  • Status changed from New to Won't fix

Thanks Jirka.

I don't think it is possible for Saxon to work around this known Xerces bug (and I'm always a bit reluctant to work around bugs in other products anyway) so I'm going to have to close this with a "won't fix" (should be "can't fix") resolution.

Also (for others): Jirka reported on xml-dev that he believes oXygen is shipped with an unreleased version of Xerces in which this bug has been fixed.

Please register to edit this issue

Also available in: Atom PDF