Re: [xml] GetLineNumber and GetColumnNumber functions for xmlReader



On Mon, Jan 03, 2005 at 11:12:48AM -0800, Aleksey Sanin wrote:
The attached patch adds GetLineNumber and GetColumnNumber functions for
xmlReader
(similar to ones found in SAX2). Please let me know if you think it is
OK to check it in.

   It's fine except their behaviour may not be what you expect.
Suppose you're on a node with the reader, user may think this correspond
to the beginning (or the end) of the position of the current node in the
XML stream. Unfortunately this is not the case, this is the position where
the push parser associated to the xmlReader stopped, which is likely to be
a bit further from the current node position, except in the case of fatal
error where the parser may have just stopped at that node.
I understand the functions description are accurate "parsing point", but
this is misleading.

  We may be able to extract the line number from the closest element node
where it is stored (see xmlGetLineNo)
  But I don't think we can precisely get back to the exact column number for
a given node except by doing heuristics. For example for an attribute
this may be very tricky.

  So I don't know what's best, maybe change the names to make sure people
don't get confused, xmlTextReaderLocatorLineNumber() is already quite
confusing. Maybe GetParserLineNumber/GetParserColumnNumber instead,

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://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]