Re: [xml] Getting line number of schema validation errors
- From: Daniel Veillard <veillard redhat com>
- To: Eric Haszlakiewicz <EHASZLA transunion com>
- Cc: xml gnome org
- Subject: Re: [xml] Getting line number of schema validation errors
- Date: Mon, 17 May 2004 22:44:12 -0400
On Mon, May 17, 2004 at 10:56:31AM -0500, Eric Haszlakiewicz wrote:
Date: Sun, 16 May 2004 15:10:40 -0400
From: Daniel Veillard <veillard redhat com>
Subject: Re: [xml] Getting line number of schema validation errors
On Sun, May 16, 2004 at 10:58:30AM +0200, Israel Ganor wrote:
xmlSchemaSetValidErrors(validSchema,
(xmlSchemaValidityErrorFunc) ErrorCallback,
(xmlSchemaValidityWarningFunc) WarningCallback,
NULL);
xmlSchemaValidateDoc(validSchema, pDoc);
However, in ErrorCallback and WarningCallback I only get general
info about
the failure, but without the line number.
It it's very helpful to tell the user that there is an error in
<USER>
element, when his XML file contains 100 such elements.
Is there a way to tell the exact error line number?
Obviously not with that API. Use the xmlSetStructuredErrorFunc()
from xmlerror.h to register a global structure error handler, then
you should get the node where the error was generated.
Daniel
oh, of course. _obviously_ not. No one would ever think that a
schema
validation error callback would be handed the line number.
Come on ! Obviously with respect to the signature of the functions
registered i.e. xmlSchemaValidityErrorFunc and xmlSchemaValidityWarningFunc
they provide only a string interface to the error funtion as you noticed !
I submitted a bug to improve
the docs for the xmlSchemaSetValidErrors() function so it references
the
more useful xmlSetStructuredErrorFunc(). (#142760)
If there a function that will take the xmlError structure and format
a pretty error message? Does the message field in the xmlError
contain the file and line number, or is that just the basic error
info?
they contain the node raising the error, then you can print
the file, line number associated or whatever contextual information
associated to the node provided.
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]