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
http://issues.apache.org/jira/browse/CONFIGURATION-307

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:

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

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

For instance:

assertEquals("Wrong value of blanc", " ",
    conf.getString("space.blanc"));
assertEquals("Wrong value of stars", " * * ",
    conf.getString("space.stars"));

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to