commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Zemann <>
Subject [configuration] best practice with nested xml files
Date Tue, 01 May 2012 11:07:50 GMT

following scenario:

I have one global config.xml which contains a regular <configuration>
and includes some further <configuration fileName="a1.xml" />
<configuration fileName="a2.xml" /> ...
The a1.xml also contains some xml references like <xml
fileName="a1_1.xml" /> <xml fileName="a1_2.xml" /> ... which the user
can input.
What is now the best practice to access these fields when i dont know
the filenames (a1_1.xml, a1_2.xml, ...)? I only know that they have a
root xml tag called <a1>

At the moment i read in a CombinedConfiguration from my config.xml and
use SubnodeConfiguration with getString("[@fileName]"), iterate over
that and create for each a SubnodeConfiguration, but i think this is a
code smell because if someone puts a1_1.xml (the xml block) into
a1.xml (which still leads to valid xml) it wont work anymore because i
reference directly to that file and not only to the field. So the user
must always use <xml fileName="..." />.

Furthermore i only need a1_1.xml in a class for identification. Lets
assume i have a field <password> in a1_1.xml and in a1_2.xml. Both xml
files start with <a1>.
First i thought "just create a CombinedConfiguration and pass it down
to all methods so i can access the configuration from everywhere". But
the problem is one class needs to know if it should now take a1_1.xml
or a1_2.xml. At the moment (as mentioned before) i pass a
SubnodeConfiguration to my class in its constructor and access its
field that way.

Any help is appreciated.

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

View raw message