Format XML output for Configuration

5 messages Options
Embed this post
Permalink
Pär Dahlberg

Format XML output for Configuration

Reply Threaded More More options
Print post
Permalink
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
Ralph Goers

Re: Format XML output for Configuration

Reply Threaded More More options
Print post
Permalink

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: [hidden email]
For additional commands, e-mail: [hidden email]

Oliver Heger-3

Re: Format XML output for Configuration

Reply Threaded More More options
Print post
Permalink
In reply to this post by Pär Dahlberg
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: [hidden email]
For additional commands, e-mail: [hidden email]

Pär Dahlberg

Re: Format XML output for Configuration

Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralph Goers
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 <[hidden email]>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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Pär Dahlberg

Re: Format XML output for Configuration

Reply Threaded More More options
Print post
Permalink
In reply to this post by Oliver Heger-3
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 <[hidden email]>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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>