commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject [configuration] Re: asking how to use xml:space (a feature do enable/disable space trimming) in XMLConfiguration
Date Sun, 02 Aug 2009 19:46:28 GMT
Note: This is a shared list, so it is common practice to put the name of 
the component you are referring to in the subject as I have done now. 
Answers below.

Dani Supriyadi schrieb:
> hello, my name is Dani Supriyadi, a programmer
> i would like to ask you how to use or implement xml:space reported by Oliver
> Heger, as described in
> i have downloaded library org.apache.commons.configuration version 1.6, and
> have imported it in my source code.
> i created a new object of XMLConfiguration, and then called a method
> getString(). But that method didn't give me any information how to
> enable/disable a process of trimming space.
> I assumed that there is another configuration embedded in some external
> files to use that features, or perhaps i need to call another method. Please
> tell me some hints...
> thank you very much..

The xml:space attribute is part of the XML specification. To enable it 
you have to place it in the XML configuration file you want to read as 
in the following example:

     <!-- Tests for handling of spaces -->
     <space xml:space="preserve">
       <blanc> </blanc>
       <stars> * * </stars>

The attribute xml:space="preserve" means that for all sub elements no 
trimming should be performed. If you have loaded this file with an 
XMLConfiguration, you can simply access the properties in the usual way 
(e.g. via getString()), and you will get the complete content including 

For instance:

assertEquals("Wrong value of blanc", " ",
assertEquals("Wrong value of stars", " * * ",


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

View raw message