You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pär Dahlberg <pe...@gmail.com> on 2009/09/24 19:51:47 UTC

Format XML output for Configuration

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.

/M v h Pär
Welcome to my blog, mostly about programming: http://www.pmdit.se/blog

Re: Format XML output for Configuration

Posted by Pär Dahlberg <pe...@gmail.com>.
Hi

I had not changed those settings, but when I tried it didn't make any
difference. I'm reading a default config in the constructor which I removed
when testing delimiter parsing disabled without success.

/M v h Pär
Welcome to my blog, mostly about programming: http://www.pmdit.se/blog


On Fri, Sep 25, 2009 at 04:33, Ralph Goers <ra...@dslextreme.com>wrote:

>
> On Sep 24, 2009, at 10:51 AM, Pär Dahlberg wrote:
>
>  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.
>>
>>
> Do you have attribute splitting and delimiter parsing disabled?
>
> Ralph
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: Format XML output for Configuration

Posted by Ralph Goers <ra...@dslextreme.com>.
On Sep 24, 2009, at 10:51 AM, Pär Dahlberg wrote:

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

Do you have attribute splitting and delimiter parsing disabled?

Ralph


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Format XML output for Configuration

Posted by Pär Dahlberg <pe...@gmail.com>.
A lot of people will probably not need formatting, so having an option to
use it for those of us who need it would be nice.

For example being able to supply ones own XSLT document to control the
output or perhaps have the option to add for example dom4j if one didn't
mind the extra library.

/M v h Pär
Welcome to my blog, mostly about programming: http://www.pmdit.se/blog


On Fri, Sep 25, 2009 at 21:28, Oliver Heger <ol...@oliver-heger.de>wrote:

> 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.
>
> Oliver
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: Format XML output for Configuration

Posted by Oliver Heger <ol...@oliver-heger.de>.
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.

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org