[xml] Re: xmlIndentTreeOutput = 1??

ok, i understand the problem so i try do make a workaround in my project.
i use more than one xml file and in one of them i will use 
xmlKeepBlanksDefault(0) and in
the other xmlKeepBlanksDefault(1).

so each function which use libxml looks now like this:

void functionA() {
int old = xmlKeepBlanksDefault(0);

my project create the xmltree by it self if the file not exist.
and now i have the effect that if the file will be create there is no 
if i read the file a second time an write in again -> it have indent?!

i also try to make

xmlSaveFormatFileEnc(filename.c_str(),doc,"UTF-8", 1);

but it not work.

so my question is: to which functions xmlKeepBlanksDefault have affection ??

"Daniel Veillard" <veillard redhat com> schrieb im Newsbeitrag 
news:20041101213256 GI20274 redhat com   
On Mon, Nov 01, 2004 at 07:16:22PM +0100, Thomas Rokohl wrote:

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:


it works. the problem is that i don't want to set 

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

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 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]