commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [ configuration ] setting top-level attributes
Date Tue, 18 Sep 2007 19:57:22 GMT
Bond - James D. wrote:
> Hopefully this is a simple one.  I have a semi-non-standard xml file that 
> has attributes in the Top-level element and I'm not able to set the 
> attributes on it.  How would I do that with XMLConfiguration?  I tried the 
> following but it didn't work:
> xmlCfg.setProperty("[@payloadID]", ""+System.currentTimeMillis());

Hm, your code should work. I added the following unit test, which runs 

      * Tests setting an attribute on the root element.
     public void testSetRootAttribute() throws ConfigurationException
         conf.setProperty("[@test]", "true");
         assertEquals("Root attribute not set", "true", conf
         XMLConfiguration checkConf = new XMLConfiguration();
         assertTrue("Attribute not found after save", checkConf

(where conf is a XMLConfiguration). As you can see, I also only specify 
the attribute part of the key.

Can you double-check with this code? Or can you provide an example code 
fragment, which does not work?


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

View raw message