You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leif Mortenson <le...@silveregg.co.jp> on 2002/03/05 08:11:22 UTC
DefaultConfigurationSerializer whitespace in XML
I was wondering if there was any way to configure SAX to create XML
which contains whitespace.
Currently the XML produced does not contain any linefeeds or whitespace.
Ie, I would like to be able to change this output:
---
<a><b><c1>foo</c1><c2>foo</c2></b></a>
---
To
---
<a>
<b>
<c1>foo</c1>
<c2>foo</c2>
</b>
</a>
---
Or something a little more human readable.
Thanks Leif
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: DefaultConfigurationSerializer whitespace in XML
Posted by Leif Mortenson <le...@silveregg.co.jp>.
Peter Donald wrote:
>Theres a method setOutputStream in DefaultConfigSerializer. You need to add a
>line similar to
>
> m_format.put(OutputKeys.INDENT,"yes");
>
You were exactly correct.
This will add line feeds after each element. It does not however do any
space indentation to place
the xml in a tree like form:
---
|<a>
| <b>
| <c1>
| foo
| </c1
| <c1>
| foo
| </c1
| </b>
|</a>
---
Still it is a lot better and more readable than before. Thanks.
>I forget exact code but the above should give you a hint. If you could make
>the serializer configurable so that it generated "nice" XML if you did
>something like
>
>serializer.setIndent( true );
>
Committed.
Cheers,
Leif
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: DefaultConfigurationSerializer whitespace in XML
Posted by Peter Donald <pe...@apache.org>.
Theres a method setOutputStream in DefaultConfigSerializer. You need to add a
line similar to
m_format.put(OutputKeys.INDENT,"yes");
I forget exact code but the above should give you a hint. If you could make
the serializer configurable so that it generated "nice" XML if you did
something like
serializer.setIndent( true );
Or at least allowed you to overide it then that would be great.
On Tue, 5 Mar 2002 18:11, Leif Mortenson wrote:
> I was wondering if there was any way to configure SAX to create XML
> which contains whitespace.
> Currently the XML produced does not contain any linefeeds or whitespace.
>
> Ie, I would like to be able to change this output:
> ---
> <a><b><c1>foo</c1><c2>foo</c2></b></a>
> ---
>
> To
> ---
> <a>
> <b>
> <c1>foo</c1>
> <c2>foo</c2>
> </b>
> </a>
> ---
>
> Or something a little more human readable.
>
> Thanks Leif
--
Cheers,
Pete
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>