After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 563562 - unrecognized XPointer schemes are not skipped silently
unrecognized XPointer schemes are not skipped silently
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.7.1
Other All
: Normal major
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-12-07 14:42 UTC by Piotr Banski
Modified: 2009-07-29 10:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (441 bytes, patch)
2009-05-18 17:11 UTC, Jakub Wilk
none Details | Review

Description Piotr Banski 2008-12-07 14:42:32 UTC
From http://www.w3.org/TR/2002/PR-xptr-framework-20021113/#scheme

(capitalization mine)

"When multiple pointer parts are provided, an XPointer processor must evaluate them in left-to-right order. If the XPointer processor DOES NOT SUPPORT THE SCHEME used in a pointer part, it SKIPS THAT POINTER PART. If a pointer part does not identify any subresources, evaluation continues and the next pointer part, if any, is evaluated. The result of the first pointer part whose evaluation identifies one or more subresources is reported by the XPointer processor as the result of the pointer as a whole, and evaluation stops. If no pointer part identifies subresources, it is an error."

xmllint ver 20632 (Cygwin) and ver 20702 (WinXP) throws an error and stops XInclude processing when presented with an unrecognized scheme, instead of skipping it and moving on. Here is a test case:

source.xml

<?xml version="1.0" encoding="UTF-8"?>
<div xmlns="http://example.org/"><p>To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.</p></div>

include-skip.xml

<?xml version="1.0" encoding="UTF-8"?>
<body xmlns="http://example.org/">
<p><xi:include  xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/div/p,'',1,47)[1]) xpointer(string-range(/ex:div/ex:p,'',1,47)[1])"/></p>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/)  string-range(/ex:div/ex:p,50,22) xpointer(string-range(/ex:div/ex:p,'',50,22)[1])"/></p>
</body>

The first <p> is here merely to show that when the processor does not identify a resource (b/c the namespace prefix is not there), it PROPERLY moves on to the second xpointer() part (where it succeeds).

It is the second <p> that bombs: the processor stops at the unrecognized scheme (which, BTW, is a proper TEI custom scheme, registered with the W3C), instead of moving on to the next pointer part. Here is the output:

$ xmllint --xinclude include-skip.xml 
parser error : unsupported scheme 'string-range'
include-skip.xml:4: element include: XInclude error : XPointer evaluation failed: #xmlns(ex=http://example.org/)  string-range(/ex:div/ex:p,50,22) xpointer(string-range(/ex:div/ex:p,'',50,22)[1])
include-skip.xml:4: element include: XInclude error : could not load source.xml, and no fallback was found
<?xml version="1.0" encoding="UTF-8"?>
<body xmlns="http://example.org/">
    <p>To make a prairie it takes a clover and one bee,</p>
    <p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/)  string-range(/ex:div/ex:p,50,22) xpointer(string-range(/ex:div/ex:p,'',50,22)[1])"/></p>
</body>

Here is the DESIRED OUTPUT (after I removed the unrecognized scheme):

<?xml version="1.0" encoding="UTF-8"?>
<body xmlns="http://example.org/">
    <p>To make a prairie it takes a clover and one bee,</p>
    <p>One clover, and a bee,</p>
</body>

I decided to set the severity of this report to major for two reasons: because this behaviour is inconsistent with the W3C specification, and because as such, it prevents the users of custom schemes from being able to fall back to the W3C schemes while waiting for their custom schemes to receive tool support. In the case at hand, it makes it difficult to test the Text Encoding Initiative's "stand-off markup" technology: 

http://www.tei-c.org/release/doc/tei-p5-doc/en/html/SA.html#SASO

xmllint is so far the only free-standing tool that provides the xpointer() scheme support for XInclude and consequently, the only tool that could at least partially support the work on stand-off markup (if we can fall back to xpointer() from our custom schemes). I hope the fix in this very case will be a snap -- thanks in advance for considering this.
Comment 1 Jakub Wilk 2009-05-18 17:11:52 UTC
Created attachment 134883 [details] [review]
proposed patch
Comment 2 Daniel Veillard 2009-07-29 10:26:36 UTC
Makes sense, applies and commited, thanks for the patch !

Daniel