You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Peter Verhas (JIRA)" <ji...@apache.org> on 2008/12/21 18:29:44 UTC
[jira] Closed: (CONFIGURATION-354) XML configuration handles
non-default list delimiter bad way
[ https://issues.apache.org/jira/browse/CONFIGURATION-354?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Verhas closed CONFIGURATION-354.
--------------------------------------
Resolution: Fixed
Fix Version/s: 1.5
I tried to modify the {{config.xml}} file as you pointed and it works fine. This also means that now I did try it out for {{ConfigurationFactory}}. :-)
I was not aware that {{config.txt}} may also define the list delimiter.
As for my case this is a very good practice. I am developing company policy regarding the use of commons config and I will discourage to use list inside XML configuration. This means that listDelimiter will be set to something like
{code}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<xml fileName="application.xml" listDelimiter="\u0000"/>
</configuration>
{code}
which will prevent to interpret any probable character as list delimiter.
Thanks,
Peter
> XML configuration handles non-default list delimiter bad way
> ------------------------------------------------------------
>
> Key: CONFIGURATION-354
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-354
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.5
> Environment: Windows XP Home edition, Java 1.6.0_07
> Reporter: Peter Verhas
> Priority: Minor
> Fix For: 1.5
>
>
> When setting the list separator character the XML configuration engine does not handle the lists properly. Sample code:
> Junit test code:
> {code}
> public void testConfig() {
> CompositeConfiguration conf = null;
> try {
> conf = (CompositeConfiguration) new ConfigurationFactory("config.xml").getConfiguration();
> } catch (ConfigurationException ex) {
> Logger.getLogger(TestConfig.class.getName()).log(Level.SEVERE, null, ex);
> return;
> }
> PrintStream o = System.out;
> conf.setListDelimiter(conf.getString("list.delimiter").charAt(0));
> o.println("c=" + conf.getString("c"));
> o.println("x="+conf.getString("key.subkey(1)"));
> o.print(System.getProperty("java.version"));
> }
> {code}
> The config.xml contains
> {code}
> <?xml version="1.0" encoding="utf-8"?>
> <configuration>
> <xml fileName="application.xml"/>
> </configuration>
> {code}
> and finally the application.xml is
> {code}
> <?xml version="1.0" encoding="windows-1250"?>
> <konfig>
> <list><delimiter>\,</delimiter></list>
> <key>
> <subkey>one,two,three</subkey>
> <subkey >four</subkey>
> </key>
> <c>${key.subkey(1)}</c>
> </konfig>
> {code}
> The resulting output is:
> {code}
> c=two
> x=two
> 1.6.0_07
> {code}
> This is correct so far. This is the case when I comment out the {{setListDelimiter}} code line. After this I change the application.xml to
> {code}
> <?xml version="1.0" encoding="windows-1250"?>
> <konfig>
> <list><delimiter>;</delimiter></list>
> <key>
> <subkey>one;two;three</subkey>
> <subkey >four</subkey>
> </key>
> <c>${key.subkey(1)}</c>
> </konfig>
> {code}
> even though I expect the same result what I got was:
> {code}
> c=four
> x=four
> 1.6.0_07
> {code}
> Do I miss some point or {{setListDelimiter}} does not work for XML files?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.