Fwd: Commons Configuration - XML Layout

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Commons Configuration - XML Layout

Brian Boyle-2
Hi there,

I'm using commons configuration for managing my xml configuration. This also
involves me writing new properties to my xml file.
When I do config.addProperty() then save it, the new property that has been
added to my xml file does not indent correctly so as to make the xml more
readable.
Is there a way that I can control this with commons configuration or is
there a workaround that I can use?

Thanks in advance,

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Commons Configuration - XML Layout

christian
Hi Brian,

i asked the same some time ago and got the answer that pretty print isn't
supported by commons-configuration. Here is how I do it (quick&easy, you
need jdom):

org.jdom.Document confDoc = *new* org.jdom.input.DOMBuilder().build(*
masterconfig*.getDocument());
*if* (confDoc != *null*) {
OutputStream output = *new* FileOutputStream(*masterconfig*.getFile());
XMLOutputter outputter = *new* XMLOutputter();
outputter.output(confDoc, output);
} *else* {
*masterconfig*.save();
}

masterconfig is the XMLConfiguration object.
hth,
best regards,
christian!



2008/11/19, Brian Boyle <[hidden email]>:

>
> Hi there,
>
> I'm using commons configuration for managing my xml configuration. This
> also
> involves me writing new properties to my xml file.
> When I do config.addProperty() then save it, the new property that has been
> added to my xml file does not indent correctly so as to make the xml more
> readable.
> Is there a way that I can control this with commons configuration or is
> there a workaround that I can use?
>
> Thanks in advance,
>
> Brian
>
Reply | Threaded
Open this post in threaded view
|

Re: Commons Configuration - XML Layout

Brian Boyle-2
Thanks Christian for your quick response.
I'll give that a try.

Cheers,

Brian

On Wed, Nov 19, 2008 at 2:17 PM, Christian Migowski <[hidden email]>wrote:

> Hi Brian,
>
> i asked the same some time ago and got the answer that pretty print isn't
> supported by commons-configuration. Here is how I do it (quick&easy, you
> need jdom):
>
> org.jdom.Document confDoc = *new* org.jdom.input.DOMBuilder().build(*
> masterconfig*.getDocument());
> *if* (confDoc != *null*) {
> OutputStream output = *new* FileOutputStream(*masterconfig*.getFile());
> XMLOutputter outputter = *new* XMLOutputter();
> outputter.output(confDoc, output);
> } *else* {
> *masterconfig*.save();
> }
>
> masterconfig is the XMLConfiguration object.
> hth,
> best regards,
> christian!
>
>
>
> 2008/11/19, Brian Boyle <[hidden email]>:
> >
> > Hi there,
> >
> > I'm using commons configuration for managing my xml configuration. This
> > also
> > involves me writing new properties to my xml file.
> > When I do config.addProperty() then save it, the new property that has
> been
> > added to my xml file does not indent correctly so as to make the xml more
> > readable.
> > Is there a way that I can control this with commons configuration or is
> > there a workaround that I can use?
> >
> > Thanks in advance,
> >
> > Brian
> >
>



--
Brian Boyle
Mobile: 087 418 5215
Email: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Commons Configuration - XML Layout

Ralph Goers
Did anyone create a Jira issue for this? If not, please do.

Ralph

Brian Boyle wrote:

> Thanks Christian for your quick response.
> I'll give that a try.
>
> Cheers,
>
> Brian
>
> On Wed, Nov 19, 2008 at 2:17 PM, Christian Migowski <[hidden email]>wrote:
>
>  
>> Hi Brian,
>>
>> i asked the same some time ago and got the answer that pretty print isn't
>> supported by commons-configuration. Here is how I do it (quick&easy, you
>> need jdom):
>>
>> org.jdom.Document confDoc = *new* org.jdom.input.DOMBuilder().build(*
>> masterconfig*.getDocument());
>> *if* (confDoc != *null*) {
>> OutputStream output = *new* FileOutputStream(*masterconfig*.getFile());
>> XMLOutputter outputter = *new* XMLOutputter();
>> outputter.output(confDoc, output);
>> } *else* {
>> *masterconfig*.save();
>> }
>>
>> masterconfig is the XMLConfiguration object.
>> hth,
>> best regards,
>> christian!
>>
>>
>>
>> 2008/11/19, Brian Boyle <[hidden email]>:
>>    
>>> Hi there,
>>>
>>> I'm using commons configuration for managing my xml configuration. This
>>> also
>>> involves me writing new properties to my xml file.
>>> When I do config.addProperty() then save it, the new property that has
>>>      
>> been
>>    
>>> added to my xml file does not indent correctly so as to make the xml more
>>> readable.
>>> Is there a way that I can control this with commons configuration or is
>>> there a workaround that I can use?
>>>
>>> Thanks in advance,
>>>
>>> Brian
>>>
>>>      
>
>
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Commons Configuration - XML Layout

christian
Ralph,
this was the answer from Oliver Heger:
http://www.mail-archive.com/user@.../msg01295.html

My interpretation of this was that it isn't considered a bug or missing
feature, so I thought it wouldn't be implemented anyway.
Of course, If you plan to change that, I can create an issue for this.

christian!


2008/11/20 Ralph Goers <[hidden email]>

> Did anyone create a Jira issue for this? If not, please do.
>
> Ralph
>
>
> Brian Boyle wrote:
>
>> Thanks Christian for your quick response.
>> I'll give that a try.
>>
>> Cheers,
>>
>> Brian
>>
>> On Wed, Nov 19, 2008 at 2:17 PM, Christian Migowski <[hidden email]
>> >wrote:
>>
>>
>>
>>> Hi Brian,
>>>
>>> i asked the same some time ago and got the answer that pretty print isn't
>>> supported by commons-configuration. Here is how I do it (quick&easy, you
>>> need jdom):
>>>
>>> org.jdom.Document confDoc = *new* org.jdom.input.DOMBuilder().build(*
>>> masterconfig*.getDocument());
>>> *if* (confDoc != *null*) {
>>> OutputStream output = *new* FileOutputStream(*masterconfig*.getFile());
>>> XMLOutputter outputter = *new* XMLOutputter();
>>> outputter.output(confDoc, output);
>>> } *else* {
>>> *masterconfig*.save();
>>> }
>>>
>>> masterconfig is the XMLConfiguration object.
>>> hth,
>>> best regards,
>>> christian!
>>>
>>>
>>>
>>> 2008/11/19, Brian Boyle <[hidden email]>:
>>>
>>>
>>>> Hi there,
>>>>
>>>> I'm using commons configuration for managing my xml configuration. This
>>>> also
>>>> involves me writing new properties to my xml file.
>>>> When I do config.addProperty() then save it, the new property that has
>>>>
>>>>
>>> been
>>>
>>>
>>>> added to my xml file does not indent correctly so as to make the xml
>>>> more
>>>> readable.
>>>> Is there a way that I can control this with commons configuration or is
>>>> there a workaround that I can use?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Brian
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>