Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-354

XML configuration handles non-default list delimiter bad way

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows XP Home edition, Java 1.6.0_07

      Description

      When setting the list separator character the XML configuration engine does not handle the lists properly. Sample code:

      Junit test 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"));
          }
      

      The config.xml contains

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
        <xml fileName="application.xml"/>
      </configuration>
      

      and finally the application.xml is

      <?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>
      

      The resulting output is:

      c=two
      x=two
      1.6.0_07
      

      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

      <?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>
      

      even though I expect the same result what I got was:

      c=four
      x=four
      1.6.0_07
      

      Do I miss some point or setListDelimiter does not work for XML files?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              verhas Peter Verhas
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: