Re: [xml] xmlIndentTreeOutput = 1??



On Mon, Nov 01, 2004 at 07:16:22PM +0100, Thomas Rokohl wrote:
hi,

i have a problem with the xmlSaveFormatFileEnc function.

if i write:

xmlIndentTreeOutput = 1;
xmlSaveFormatFileEnc("test.xml",doc,"UTF-8", 1);

there is no indent in the file, but if i use:

xmlKeepBlanksDefault(0)

it works. the problem is that i don't want to set xmlKeepBlanksDefault(0).

so what's wrong by the first way?

i think the difference between this two way's for setting 
xmlIndentTreeOutput is that den second way is an function call in the 
library. but

  The core of the issue is the following:
    - if libxml2 sees a text node child for a node, it won't indent
      the output of that node to avoid destroying mixed content data
    - this policy also affects existing text nodes used for previous
      indenting.

xmlKeepBlanksDefault(0) removes all existing indentation nodes. Yes this
is bad, it's an heuristic. But expecting xmlSaveFormatFileEnc() to add 
subch blanks or modify them is also an heuristic, as dangerous.
In a nutshell only the application can really know if spaces are ignorable
or not in an instance, and relying on the parser/toolkit to do so is not
safe. There is no easy solution.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
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]