Re: [xml] Error handling with the XmlReader API



On Thu, Jan 16, 2003 at 09:38:43AM +0100, Stéphane Bidoul wrote:
Here are 2 more arguments to put in the balance.

First, my proposals lack locator information. That's probably easier
to add to the callback method than the getLastError approach.

  yup,

Second, C# has a mechanism to use callbacks instead of exception to report
validation errors (the user can choose). For well-formedness
errors, exceptions are always thrown.

  Okay,

I guess one could conceive variations on the getLastError theme
to correlate errors with nodes but that would be complex to implement
and to use, IMO.

So I would vote for the callback approach, with locator information.

  fine,

typedef void (*xmlTextReaderErrorFunc)(
   void *arg, const char *msg,
   int line, int col, const char *uri, int severity);

int xmlTextReaderSetErrorHandler(
   xmlTextReaderPtr reader, xmlTextReaderErrorFunc f, void *arg);

After all, I think it's not a good idea to give the xmlTextReaderPtr to
the callback, because when the callback is invoked, the reader
is not necessary in a valid state? 

Errors will be generated only when the reader pushes new data at the
beginning of a Read(). It's not tightly coupled to the Reader state
itself, this would require some double checking before asserting it's
a safe state though.

However providing a user argument is probably necessary.

  Yes definitely needed !

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.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]