Re: [xml] Query regarding empty nodes creation during document parsing,



On Fri, Nov 09, 2007 at 02:22:28PM +0800, nagesh wrote:

   Hi,

           I have a query regarding the creation of DOM tree when parsing
   the  xml  document.  I  am working on libxml2-2.6.28. I am parsing the
   document  buffer with the API xmlReadMemory( ) with XML_PARSE_NOBLANKS
   options set.

  Do *NOT* do that. This puts the parser in a non-compliant mode, result
will be hazardous.

           However for the xml buffer like,

   "<types>\r\n"

              "<schema/>\r\n"

    "</types>\r\n"

           It does not create a blank node, but whereas for the buffer,

           "<types>\r\n"

           "</types>\r\n"

           It does create a blank node as the child of element "types". I
   just  had  a  peed into the parser code, and I have done the following
   fix to overcome this problem.

  There is no way to know for sure whether a blank node is significant
or not. The standard says *always keep them*, the XML_PARSE_NOBLANKS options
still tries to do some guesses, but since there is no proven algorithm 
which works (c.f. decades of SGML experience) this is an heuristic,
and there is no garanteed result. Don't expect a reliable behaviour from
this option, do not use it, only the application can tell if a blank
node is significant or not.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]