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



Le Jeudi 8 Mai 2003 15:43, Murray Cumming Comneon com a écrit :
>  > 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.
>

The difference I see is that the parser classes restore the previous value, 
but not the parse functions in document.cc

[...]
> > 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++/libx
>m 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.

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

Significant no, but very usefull yes. If one have to read the xml file it will 
be a *lot* easier.

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

Certainly

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

Ok. I agree with that.



I made a few tests:

Document::write_to_string() does not format the output

Document::write_to_file() does format the ouput BUT if we use some 
Parser::parse_xx function before, it will not (and the ouput is different to 
the one of write_to_string()).

So we have an inconsistent behavior anyway.


Regards 

Christophe




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