Re: [xml] Getting line number of schema validation errors

On Sun, May 16, 2004 at 10:58:30AM +0200, Israel Ganor wrote:

I validate XML files vs. a schema asfollows:

              (xmlSchemaValidityErrorFunc)   ErrorCallback,
              (xmlSchemaValidityWarningFunc) WarningCallback,

    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 Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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