Hi Oliver

No i cannot assign names to the configurations as i dont know them - the user should be able to add them so i dont know what the user will enter.
I will see that i provide you an example this weekend.

Thanks for your help.

Oli

Am 02.05.2012 21:44, schrieb Oliver Heger:
Am 01.05.2012 13:07, schrieb Oliver Zemann:
Hi

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.
Thanks!

Sorry, but I don't really understand what you want to achieve. Maybe you can elaborate some more on the use case?

Just one suggestion (with limited understanding of your issue): Can you assign names to the included child configurations (using the config-name attribute) and then ask the combined configuration for specific sub configurations? CombinedConfiguration has the methods getConfigurationNames() and getConfiguration(String name).

Oliver


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Attachment: smime.p7s
Description: S/MIME Kryptografische Unterschrift

Reply via email to