'Re: [xml] "xmlReadxxx & structured error handler & userData'



Hi,

on 2/12/2004 4:53 PM Kasimier Buchcik wrote:

Hi,

on 2/12/2004 4:40 PM Daniel Veillard wrote:
On Thu, Feb 12, 2004 at 04:36:08PM +0100, Kasimier Buchcik wrote:

Yes, I wasn't sure about this. But the dilemma is that I can set 
*nothing* on the context, no userData nor _private, since the 
xmlParserContext is created inside the xmlReadxxx functions.

 Then you need the xmlReadCtxtxxx functions, they are usually
dedicated to repeated parsing but if you need to access the context
that's the way. Apparently there is no example in 
   http://xmlsoft.org/examples/index.html
demonstrating their use but xmllint.c does, e.g.

   ctxt = xmlNewParserCtxt();
   /* tweak ctxt here */
   doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
   /* when you're done */
   xmlFreeParserCtxt(ctxt);


Great! I missed that one.
Maby one should change the doc for "xmlSetStructuredErrorFunc", since 
@ctx will *not* be always passed as the first argument to @handler.

It works fine!

set the ctxt->_private to my context;
in the error handler check for error->domain = XML_FROM_PARSER and get 
my context with userData->_private.

Apparently the structured error handler is not called at all if I set 
ctxt->userData - your concern was truly legitimated.


Thanks,

Kasimier




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