I am using the xmlTextReader interface in
conjunction with structured error handling to intercept errors/warnings:
int flags = XML_PARSE_RECOVER | XML_PARSE_NOENT |
XML_PARSE_DTDVALID;
xmlTextReaderPtr reader = xmlReaderForFile(“somfile.xml”,
NULL, flags);
xmlTextReaderSetStructuredErrorHandler(reader, myxmlStructuredErrorFunc,
NULL);
int status = 1;
while (1 == status) { status = xmlTextReaderRead(reader);
}
It seems that while errors related to well-formedness
trigger myxmlStructuredErrorFunc, errors related to validity do not. If instead
I use the other error handling technique via:
xmlTextReaderSetErrorHandler(reader, myxmlTextReaderErrorFunc,
NULL);
then I find that myxmlTextReaderErrorFunc is
triggered for both kinds of errors. However, this type of error handling does
not seem to give me the correct line numbers (via xmlTextReaderLocatorLineNumber(locator)).
The problem it seems is that inside error.c::__xmlRaiseError(),
the ‘schannel’ variable does not get set because the domain in
these instances is XML_FROM_VALID. I have changed this if statement to
include this case, and now my error handler gets called appropriately.
I want to know if this is a bug, or if this is by
design, and if it’s by design, how can I either trigger structured error
handling for validation errors, or retrieve correct line numbers for the
other error handling mechanism?
I’m using v2.6.14 on Windows, VC++ 7.1. Thanks
in advance for any help.
-Parag Chandra
|