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



Thanks. xmlSetStructuredErrorFunc() gives me the error line mumber.
xmlGetLastError() returns the same error details.
Is there any difference between using the above two API's for schema
validation?

Thanks in advance

Israel Ganor







-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Sunday, May 16, 2004 9:11 PM
To: Israel Ganor
Cc: 'xml gnome org'
Subject: Re: [xml] Getting line number of schema validation errors


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

I validate XML files vs. a schema asfollows:

    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

-- 
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]