The code that is replaced by this change is designed to implement the rule: "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".
If an external entity reference in a document is expanded to produce a new element, the only way we know that the element had no parent within the external entity is that the systemId of the element is different from the systemId of the parent element. In this case we are supposed to resolve against the systemId of the external entity.
The problem is, that when the XInclude processor puts an xml:base attribute on the generated element, it is expecting it to be resolved against the base URI of the new parent element, not against the systemId of the included entity. And Saxon can't easily distinguish the two cases.
I'm going to raise a question on xml-dev about this to see if any of the XML gurus have a view on it.
Here's the message I have posted:
Patrik Stellman raised a problem on the saxon-help list for which I would appreciate advice.
When an external entity is expanded, and the entity in question contains an element with an xml-base attribute, the value of the @xml:base attribute is supposed to be resolved against the base URI of the external entity itself (not against the base URI of the element into which the entity's expansion is grafted).
But when xi:include is processed, the xi:include processor injects an @xml:base attribute which is intended to be resolved against the base URI of the "include parent" (that is, the parent of the xi:include element).
Saxon, as receiver of events notified by the XML parser, is interpreting the two situations in the same way. If the systemId of an element is different from the systemId of its parent, it assumes that the child element was produced by entity expansion, and that the @xml-base attribute should therefore be resolved relative to the systemId of the child element. But this ignores the possibility that the child element was actually produced by XInclude expansion: this will also cause the child element and parent element to have different SystemIds (as notified by a SAX parser), but this time the @xml-base attribute should be resolved against the base URI of the (new) parent element.
Can anyone suggest a way in which Saxon, as receiver of SAX events, can distinguish the two cases and interpret them both correctly?