commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose M. Rus" <>
Subject [configuration] writing an XML document with XMLConfiguration
Date Mon, 06 Sep 2004 12:28:07 GMT
I am working on a XML configuration file that stores the next structure:

    <name>blah blah</name>

Previously, with the now gone ConfigurationXMLDocument class, I simply 
would write this part of the document with some code like this:
        ConfigurationXMLDocument = ...
        config.addProperty("", "blah blah");
        config.addProperty("", "");

But now when I use XMLConfiguration in the same way I simple lose the 
<author> container so the result is:
<name>blah blah</name>

I solve this situation by deliberately writing the empty container tag 
(config.addProperty("author", "")), something that was not needed 
before. Is this the right behaviour of XMLConfiguration? Do I needed to 
provide it with empty container tags for every property that is nested?

And how can I access the top level tag of the generated XML document by 
XMLConfiguration? I want to replace "<configuration>" with a more 
suitable value depending of the file. ConfigurationXMLDocument.write() 
and HierarchicalDOM4JConfiguration.getRoot() allowed this before.

Another comment about the notation of XMLConfiguration. The constructor 
to read from a file uses a File argument (the String argument is 
reserved to read from a resource) but the method to write to a file uses 
a String argument. I would also use a File argument to write to a file 
(more symmetric) and simply not implement the string one (a resource is 
read only).

    Jose M. Rus.

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

View raw message