[xml] xpointer error



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,'&#160;',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,

  Piotr



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]