commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose M. Rus" <jm...@euneo.com>
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:

[...]
<author>
    <name>blah blah</name>
    <email>blah@blah.com</email>
</author>
[...]

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

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

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

Regards,
    Jose M. Rus.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message