RE: [libxml++] writing formatted (indented) files



 > Le Jeudi 8 Mai 2003 14:32, Murray Cumming Comneon com a écrit :
> > > From: Christophe de Vienne [mailto:cdevienne alphacent com]
> > Hold on. Be careful. Isn't xmlKeepBlanksDefault() all about 
> breaking the
> > XML specification for libxml backwards compatibility:
> > http://xmlsoft.org/html/libxml-parser.html#xmlKeepBlanksDefault
> >
> > I thought we had already chosen the correct use of it.
> 
> I see. The confusion comes from the fact that I was looking 
> at the parse_xxx 
> functions which are inside document.cc, which does a 
> xmlKeepBlanksDefault(0).
> The parsing methods in SaxParser and DomParser does the right thing.

But they both do the same thing.

This is a line in document.cc:

"
// Don't use libxml1 compatability. This is the default anyway.
xmlKeepBlanksDefault(0);
"

This is a line in parser.cc, used by both SaxParser and DomParser:
"
_context->keepBlanks = CONSTANT_KeepBlanksSetting; // FALSE - This is the
default anyway.
"

Maybe you are confused that we use xmlKeepBlanksDefault() at all. But we
just set it to what it should be already, in case something else has set it
wrongly. We should always store the setting and restore it afterwards,
however.

> I propose to take them off since they are not behaving 
> consistently with what 
> Parsers do.
> 
> Anyway it seems that  xmlKeepBlanksDefault(0) is not the 
> default inside 
> libxml2,

But I obviously thought it was, because that's why I put that comment in
document.cc, quote above:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/libxmlplusplus/libxml++/libxm
l%2b%2b/document.cc?rev=HEAD&content-type=text/vnd.viewcvs-markup

I could be wrong, but I remember doing a lot of checking to find out.

> since without calling it the output is not formatted.

Daniel would probably tell you in strong terms that formatting is
significant therefore libxml shouldn't do it. Some formatting is not
significant though, I think.

You can be sure that the libxml default is now for XML specification
compliance.

> One solution would be to do in Document what we to in Parser 
> : define a 
> constant we use in write_to_xx and then restore the previous value.
> 
> Talking about this : the Parsers do a call to 
> xmlKeepBlanksDefault(CONSTANT_KeepBlanksSetting), but there 
> is no way for the 
> user to change the value.

Because they shouldn't have to ever change it. It's only for backwards
compatibility with a broken libxml 1, and libxml++ people don't care about
libxml 1.

> Wouldn't be better to add a function to Parser which change 
> it (and do the 
> same with Document) ?

No, we used to have that, and we removed it because it was useless. I don't
want to add any please_break_the_xml_specification() functions.

Murray Cumming
murrayc usa net
www.murrayc.com 




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