Re: [xml] xpointer error
- From: Daniel Veillard <veillard redhat com>
- To: Piotr BaÅski <bansp o2 pl>
- Cc: xml gnome org
- Subject: Re: [xml] xpointer error
- Date: Thu, 27 Nov 2008 15:41:52 +0100
On Wed, Nov 26, 2008 at 04:04:15PM +0100, Piotr BaÅski wrote:
Hello,
Daniel -- first of all, thanks so much for implementing the xpointer()
scheme -- I can try it out at last :-)
There is a problem that I get under both libxml 2.6.32 and 2.7.2,
illustrated by the following, which is a test case for extracting
substrings for the purpose of text annotation:
include2.xml
<?xml version="1.0" encoding="UTF-8"?>
<body><p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml" xpointer="xpointer(string-range(/div,'',1,47)[1])"/></p>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml" xpointer="xpointer(string-range(/div,'',50,22)[1])"/></p>
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,'',73,11)[1])"/></p></body>
source.xml
<?xml version="1.0" encoding="UTF-8"?>
<div><p>To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.
The revery alone will do,
If bees are few</p></div>
-----------
$ xmllint --xinclude --debug include2.xml
Internal error at
/usr/src/ports/libs/libxml2/libxml2-2.6.32-2/src/libxml2-2.6.32/xpointer.c:2409
Internal error at
/usr/src/ports/libs/libxml2/libxml2-2.6.32-2/src/libxml2-2.6.32/xpointer.c:2409
DOCUMENT
version=1.0
encoding=UTF-8
URL=include2.xml
standalone=true
ELEMENT body
ELEMENT p
INCLUDE START
TEXT
content=To make a prairie it takes a clover and ...
INCLUDE END
TEXT compact
content=
ELEMENT p
INCLUDE START
TEXT
content=One clover, and a bee,
INCLUDE END
TEXT compact
content=
ELEMENT p
INCLUDE START
TEXT
content=And revery.
INCLUDE END
The error goes away in two cases: when I comment out the two latter
<p>s, or when I put a designated character at the the very beginning of
the source.xml text, and match against it, e.g.:
<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="source.xml"
xpointer="xpointer(string-range(/div,' ',3,48)[1])"/></p>
The error context in xpointer.c is in xmlXPtrAdvanceChar():
if (pos > len) {
/* Strange, the indx in the text node is greater than it's len */
STRANGE
pos = len;
}
And I can't see what I possibly do wrong here. Thought I'd let you know,
in case the problem was xmllint's.
The relevant fragment of the xpointer draft is at
http://www.w3.org/TR/xptr-xpointer/#stringrange
Best regards,
Honnestly I don't remember, I implemented that 8 years ago and it
didn't got much use since then. It's likely there is bugs, and while
string ranges have some regression tests they seems to only test rather
small ranges.
Somehow I don't think you can use /div and expect to have ranges
working under a children of the div, maybe you misunderstood the spec.
But the error raised by libxml2 doesn't look great either.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]