Re: [xml] Issue with xmlParseInNodeContext and xmlParseCharData()



Hi,

Great, your patch fixed my issue. Actually, im my case, the context node passed to xmlParseInNodeContext() is a xmlDocPtr, and then the instate variable was not set to XML_PARSER_CONTENT.

Thanks,
Frank

Le 21/03/2014 10:08, Daniel Veillard a écrit :
On Wed, Mar 19, 2014 at 06:29:08PM +0100, Frank Gross wrote:
Hi,

   Since libxml 2.8.0 I have an issue when I use
xmlParseInNodeContext(). During the parsing, it goes through the
xmlParseCharData() function where following test has been added
compared to libxml 2.7.2. And this test makes my parsing fail. For
instance, the node I parse is <a><b>data</b><c>other</c></a> and in
both libxml versions the ctxt->instate value is always
XML_PARSER_START, but with that test since libxml 2.8.0, an error is
raised when parsing the first text node.

Shouldn't the ctxt->instate value be set to XML_PARSER_CONTENT when
starting to parse the content from xmlParseInNodeContext() ? Or can
someone tell me what I'm doing wrong or maybe why that test has been
added ?


File parser.c at line 4321 :

                 /* something really bad happened in the SAX callback */
                 if (ctxt->instate != XML_PARSER_CONTENT)
                     return;

Regards,
Frank
   Hum, yes that sounds right !
libxml2 does set ctxt->instate to XML_PARSER_CONTENT but only if the
node passed to graft the resulting data is an ELEMENT, that too limited
I think, could you try with the following patch ?
  https://git.gnome.org/browse/libxml2/commit/?id=6faa126fc3ba24a782e832cb0000d6d4f6b7b576

A workaround is to make sure the node you pass as first parameter
of xmlParseInNodeContext is an element.

Daniel


--
Frank GROSS
Software Engineer - Web Services
Four J's Development Tools - http://www.4js.com



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