Re: [xml] [Bug 143739] - incorrect line numbers in well-formedness error message
- From: "R. Steven Rainwater" <srainwater ncc com>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] [Bug 143739] - incorrect line numbers in well-formedness error message
- Date: Fri, 02 Jul 2004 13:50:03 -0500
On Fri, 2004-07-02 at 04:01, Daniel Veillard wrote:
Now all error messages display the same, incorrect line number:
Well-formedness Error [line 65535]: Char 0xD96B out of allowed range
Do you use specific error reporting mechanism ?
I'm using a function called xmlTextReaderLocatorLineNumber(locator) to
determine the line number.
Here's the entire libxml2-related code - just two small functions. It's
pretty minimal:
/*
* wfErrorFunc - used by isWellFormedXML to handle errors
*/
void wfErrorFunc(void *arg, const char *msg, xmlParserSeverities
severity, xmlTextReaderLocatorPtr locator) {
const char *err[5] = {
"",
"Validity Warning",
"Validity Error",
"Warning",
"Error"
};
printf("Well-formedness %s [line %i]:
%s",err[severity],xmlTextReaderLocatorLineNumber(locator),msg);
}
/*
* isWellFormedXML: Checks XML well-formedness acccording to the W3C
* XML 1.0 definition. http://www.w3.org/TR/REC-xml
* Based on the streamFile function from xmllint.c, part of the libxml
* library by Daniel Veillard.
* http://xmlsoft.org/
*
*/
static int isWellFormedXML(char *filename) {
xmlTextReaderPtr reader;
int ret = 1;
reader = xmlNewTextReaderFilename(filename);
if (reader != NULL) {
xmlTextReaderSetErrorHandler(reader,wfErrorFunc,NULL);
while (ret == 1) {
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
}
else {
fprintf(stderr,"Error: unable to open [%s]\n",filename);
exit(1);
}
if(ret != 0) return 0;
return 1;
}
The entire source for the dumpcheck program is available here:
http://rainwaterreptileranch.org/steve/sw/odp/
-Steve
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]