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

On Wed, Mar 19, 2014 at 06:29:08PM +0100, Frank Gross wrote:

  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)


  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 ?

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


Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit | virtualization library

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