Re: [xml] Blank nodes problem

On Wed, Dec 03, 2003 at 05:45:51PM -0500, Ed Day wrote:
I am working on a DOM application in which I would like to suppress the generation of blank nodes to make 
the tree easier to work with.  To do this, I call xmlKeepBlanksDefault(0) which seems to work pretty well.  
However, I have recently run across a situation in which I have found that if a line in an XML file does 
not end with a newline character immediately after the closing '>' character, a blank node is inserted into 
the DOM tree.  In other words, some extra whitespace is present before the newline. 

For example (using \n to represent newline), this is OK (no blank nodes):


this causes a blank node:

<a>  \n

Is this the way it is supposed to work (i.e. is this considered 'significant' whitespace) or is this a bug?

  All data whitespace are significant. Only the application really knows 
what can be discarded. The xmlKeepBlanksDefault() is a trick, a leftover
from legacy APIs, it's bad in a number of ways including the fact that
it uses a global variable for changing the library behaviour.
  I don't think it can be considered a bug, the behaviour can't really
be rationalized (people have tried historically and failed), with or
without xmlKeepBlanksDefault(0) some processing and checking is expected
at your level.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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