commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: Format XML output for Configuration
Date Fri, 25 Sep 2009 19:28:29 GMT
Pär Dahlberg schrieb:
> Hi
> I got a Commons Configuration question. Is there some easy way to format the
> XML output from an XMLConfiguration?
> Reading a config file and saving it works very well. However each time the
> file is saved a couple of empty lines are inserted between random elements.
> The file is of course still usable, but it looks quite bad when editing by
> hand after beeing saved a few times.

XMLConfiguration stores the DOM tree obtained from the parser. When 
saving, the tree is written using an XSLT identity transformation. This 
should normally not mess up the formatting.

However, if properties are modified or added, the nodes created by these 
operations typically do not match the format of the other nodes which 
causes poor results when writing the configuration back to disk. Also 
creating a new XML configuration produces unformatted documents.

Does anybody have an idea how a better formatting could be implemented? 
In the early days we used a library like dom4j for XML handling. This 
produced nice-looking documents, but the price was an additional 
dependency. I don't think we should go back.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message