Re: [libxml++] writing formatted (indented) files
- From: Christophe de VIENNE <cdevienne alphacent com>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] writing formatted (indented) files
- Date: Fri, 16 May 2003 10:06:28 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le Vendredi 16 Mai 2003 08:46, Murray Cumming Comneon com a écrit :
> > 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.
>
> I have added the examples/dom_read_write/ test in cvs and it does
> demonstrate this obvious and serious problem - we are removing significant
> white space. Christophe, I believe you have a solution for this, but I'll
> try to take care of it if you want me to.
>
The very first thing to do is, I think, not to use xmlSaveFormatFile, at least
the way we do (I mean setting the 'format' parameter to 1 is bad). I'd prefer
to use xmlSaveFile(), and add a member function save_to_format_file() to
Document.
If you agree with that (I guess you will) I'll commit it today.
But the behavior we observe reveal something strange into libxml2 :
It seems that xmlKeepBlanksDefault(0) is the default. Indeed, calling
xmlSaveFormatFile(...) with format=1 do indent the file.
If we change it then restore previous value, which is what we do in the
XXXParser classes, it should be exactly like calling xmlKeepBlanksDefault(0),
or doing nothing. But after this operation the file is not indented anymore
when using xmlKeepBlanksDefault(0).
This means that the restoration of previous value is not working. I know it is
not a problem if we use xmlSaveFile, but it may brake something we don't see
yet.
At least we'll have to change a bit what we do about xmlKeepBlanksDefault().
- Either we do not call it at all, assuming it is libxml2 default (and since
we rely on a quite recent version I think it's safe).
- either we use it, but have to figure out why we have this behavior, and
then use it exactly the same way in all functions it is needed (I mean
save/restore it).
For now I prefer the first solution.
I want to do a few tests and reproduce the case with pure libxml2, and if I
have valuable information about it I'll post something on xml-list.
Regards,
Christophe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+xJwIB+sU3TyOQjARAtTqAJ4s16vHwYz70HuWopzl64WcTdyL5QCeMgdT
gii1hb86nF37yHQUkATsG7g=
=5Ew5
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]