Further details of this problem can be found here: We have the following structure: root.xml:
subfolder/child.xml:
subfolder/otherchild.xml:
The Xerces parser (both the Apache and JDK versions) presents Saxon with a document like this: <root xmlns:xi="..."> <child xml:base="subfolder/child.xml"> <otherchild xml:base="subfolder/otherchild.xml"/> </child> </root> and as a result, Saxon reports the base URI of <otherchild> as xxx/subfolder/subfolder/otherchild.xml. My question is: is Xerces getting this wrong, or is Saxon? The spec for xml:base says (ยง4.3) 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. It's a bit hard to interpret that, because by the time the elements have acquired an xml:base attribute, they are no longer part of any document or external entity. But I can only see two possible interpretations: (a) otherchild/@xml:base is resolved against the base URI of the <child> element, which gives the result Saxon is showing, and (b) otherchild/@xml:base is resolved against the base URI of the entity that the <otherchild> element originally came from, which gives exactly the same result. Would anyone argue that the Xerces output is correct? Michael Kay Saxonica |