Re: [xml] Error handling on a per-parser base



On Thu, Oct 28, 2010 at 05:44:03PM +0100, R. Mattes wrote:
On Thu, 28 Oct 2010 18:27:54 +0200, Daniel Veillard wrote
On Mon, Oct 25, 2010 at 09:09:03PM +0000, Ralf Mattes wrote:
Hello list,

is it possible to register a custom error function per xmlParserCtxtPtr
created by xmlCreatePushParserCtxt? I'd like to parse documents in 
parallel and would need error reporting per parser context. Dispatching
on user_data in the error callback seems inside out.

  You can set the ctxt->sax->serror assuming a SAXv2 to set a structured
error handler. But in general the disambiguation will be done based 
on the context not based on the function.

Hm, I don't seem to understand: what context are you talking about, the
xmlParserCtxt I created, or the userdata context I provide as the first
parameter to xmlSetGenericErrorFunc and the like?

  either should work for this :-) By default libxml2 tend to use
the parser context precisely as the data for the default handler.

Setting a general 
strcutured error handler should then allow this.  But note that some 
errors may occur in part of the code where the parsing context may 
not be available, and there you won't be able to disambiguate,

Bummer!

  Yeah, if I were to write libxml2 from scratch now I would ban any
global variable, but that's design from 10-13 years ago :-\

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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