Re: [xml] validating SAX parser and error line numbers
- From: Daniel Veillard <veillard redhat com>
- To: Joel Uckelman <uckelman nomic net>
- Cc: xml gnome org
- Subject: Re: [xml] validating SAX parser and error line numbers
- Date: Thu, 27 Jun 2013 22:26:14 +0800
On Tue, Jun 18, 2013 at 06:53:09AM -0700, Joel Uckelman wrote:
Thus spake Joel Uckelman:
2) If after a call to xmlParseDocument(), I find that !ctx->wellFormed,
is there a way to get an accurate indication of where things went wrong?
As with my example above, if I have "<blerg" on line 12 and call
xmlParseDocument(), after that the ctx->input->line is one more than the
last line of input---i.e., it appears that the parser read to the end in
a desparate attempt to find a closing '>'.
I'm still hunting for a good solution for #2. The best idea I've had
so far is for each SAX callback to update a variable containing the
line number at the time it's run. This way, that variable (call it
"goodline") will contain the number of the last line on which anything
was successfully processed. I would think that libxml must already have
this information, if only I knew where to look for it.
It was looking like you had fixed your problem, hence the absence of
reply from my part.
Does libxml2 not support this kind of thing? Anyone?
SAX makes things more complex in general.
Did you register a error handler in your sax handler. Or even better
a xmlStructuredErrorFunc serror handler ?
The xmlErrorPtr that you get in the callback should have all the
informations.
If you don't like the idea of getting errors in a callback, why use
SAX in the first place ?
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]