[xml] validating SAX parser and error line numbers

I'm having two problems with line numbers and error reporting:

1) I'm using xmlSchemaSAXPlug() to validate against a schema when I
parse. When my xmlStructuredError callback is called with a validation
error, the the line and int2 (which is supposed to be a column?) are
always zero, regardless of where the error is in the input. E.g., If I
have an element "<blerg/>" on line 12 which isn't permitted by the
schema, and I print the error mesage like so:

  std::cerr << err->line << ',' << err->int2 << ": " << err->message << '\n';

I get this as output:

  0,0: Element 'blerg': This element is not expected.

So, clearly the validator knows where the error is, but that's not
getting into the xmlErrorPtr my error callback receives.

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 '>'.

In both cases, I'd like to be able to report to the user the line where
the problem began. How can I do that?


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