Hi all,
I am encountering the following strange behavior with regard to xml:base. Here is an example:
----[ 1.xml ]---- <?xml version="1.0"?> <top xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href=""> </top> ------------------
----[ dir/2.xml ]---- <?xml version="1.0"?> <elem1 xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href=""> </elem1> ---------------------
----[ 3.xml ]---- <?xml version="1.0"?> <elem2> <a fileref="x.svg"/> </elem2> ------------------
Now, if I process 1.xml with 'xmllint --xinclude', I get:
$ xmllint --xinclude 1.xml <?xml version="1.0"?> <top xmlns:xi="http://www.w3.org/2001/XInclude"> <elem1 xmlns:xi="http://www.w3.org/2001/XInclude" xml:base="dir/2.xml"> <elem2> <a fileref="x.svg"/> </elem2> </elem1> </top>
The question is, why is xml:base missing on elem2? It is included from a different location than its ancestor, elem1. Is it a bug in libxml2, or am I missing something in the XInclude specification? As far as I can see, XInclude says:
"Each element information item in the top-level included items which has a different base URI than its include parent has an attribute information item added to its attributes property."
In this case base URI for elem2 is different than that for elem1 - so I think xml:base should be present.
This affects DocBook stylesheets: when they attempt to insert the references to external graphics (e.g. fo:external-graphic for XSL-FO output), they analyze xml:base on all of the element's ancestors. With inclusion like this, it incorrectly resolves the file reference like a/@fileref above to point to dir/x.svg. Any workarounds?
I am using 2.9.0 now, haven't tried with the "bleeding edge" yet.
Regards, Alexey. |