Inconsistent namespace URI normalization breaks XPointer evaluation
This is a refiling of bugzilla:731065 from 2014.
Summary:
Inclusion with XInclude fails for URIs containing a ':' (and possibly other characters) in the path part because different parts of the code normalize namespace URI strings differently which leads to failing comparisons. This makes it impossible to use libxml2 and XInclude with e.g. OpenDocument documents.
Reproducer:
$ cat data.xml
<?xml version="1.0"?>
<rootB xmlns="abc://d/e:f">
</rootB>
$ cat xinc.xml
<?xml version="1.0"?>
<rootA xmlns="wxy://z" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="data.xml" xi:xpointer="xmlns(b=abc://d/e:f) xpointer(/b:rootB)"/>
</rootA>
Inclusion with XInclude fails:
$ xmllint --xinclude xinc.xml
xinc.xml:3: element include: XInclude error : XPointer evaluation failed: #xmlns(b=abc://d/e:f) xpointer(/b:rootB)
xinc.xml:3: element include: XInclude error : could not load data.xml, and no fallback was found
<?xml version="1.0"?>
<rootA xmlns="wxy://z" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="data.xml" xi:xpointer="xmlns(b=abc://d/e:f) xpointer(/b:rootB)"/>
</rootA>
Replacing "e:f" with "e_f" makes it work:
$ sed 's@e:f@e_f@g' -i data.xml xinc.xml
$ xmllint --xinclude xinc.xml
<?xml version="1.0"?>
<rootA xmlns="wxy://z" xmlns:xi="http://www.w3.org/2001/XInclude">
<rootB xmlns="abc://d/e_f">
</rootB>
</rootA>
I won't repeat the analysis I wrote in Bugzilla here.