Re: [xml] REPOST: xmlTextReader And RelaxNG (was Accurate Line Numbers?)



On Mon, Feb 23, 2004 at 08:33:07AM -0800, Reid Spencer wrote:
<serious egg on my face>

I added xmlTextReaderGetLocator a few months ago and forgot about it! I
had made other changes and abandoned them with cvs update -C but this
change stuck for some reason (probably because I was using it).  I
thought I was dealing with a clean cvs checkout, but obviously I'm not. 

  Okay,

So, perhaps my original question was more accurate:

How does one *correctly* get line number information from the
xmlTextReader interface?

  The best way would be to extract the line number information from
the current node in the reader. The locator stuff is not appropriate to
xmlReader since libxml2 does some tree buffering.

In CVS there is only one way to obtain an 
xmlTextReaderLocatorPtr and that is via the error callback. I added
xmlTextReaderGetLocator to allow me to get the locator in non-error
situations.  Suppose I wanted to print the correct line number for every
start tag (or end tag) that is encountered during xmlTextReader parsing?
How should I do it?

  You can't get start and end from the node. Getting both would require
patching the xmlTextReader to store those informations "somewhere".

If you want to try the test program, you'll need the patch that is
attached. It provides the declaration and definition of 
xmlTextReaderGetLocator. The patch was generated with cvs diff -Nacp. In
case you're concerned, this patch constitutes the entire local changes
I've made to libxml2. Everything else is as it was in CVS a few days
ago.

Sorry for the confusion, life's been hectic here the last few months.

  No problem,

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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