You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Oliver Zemann <ol...@googlemail.com> on 2012/04/19 16:05:51 UTC
[configuration] recursive inclusion of xml files with fileNames tag
Hi,
just a short question:
is it possible to include recursive all xml files that are referenced
by any already included xml?
eg.:
root.xml:
<?xml version="1.0" encoding="UTF-8"?>
<additional>
<xml fileName="other.xml" config-name="another"/>
</additional>
other.xml:
<?xml version="1.0" encoding="UTF-8"?>
<xml fileName="other1.xml" config-name="another1"/>
<xml fileName="other2.xml" config-name="another2"/>
...
?
I tried it but they are simply ignored. Only the first recursion level
(other.xml) is handled, all elements in other1.xml other2.xml ... are
ignored.
Can i somewhere put a recursive flag to the configuration?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [configuration] recursive inclusion of xml files with fileNames
tag
Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Oliver,
Am 20.04.2012 08:59, schrieb Oliver Zemann:
> Hi Oliver ;)
> Thanks for your help.
>
> I tried it with the following code/config:
>
> public static void main(String[] args) {
> CombinedConfiguration conf = null;
> try {
> DefaultConfigurationBuilder builder = new
> DefaultConfigurationBuilder(new File("conf/conf.xml"));
>
> conf = builder.getConfiguration(true);
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> Iterator<String> keys = conf.getKeys();
> }
>
> conf.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration>
>
> <configuration fileName="conf1.xml" />
> <configuration fileName="conf2.xml" />
> <configuration fileName="conf3.xml" />
>
> </configuration>
>
> conf1.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <conf1>
> <name>conf1</name>
> <xml fileName="conf1extend.xml" />
> </conf1>
>
> conf1extend.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <ext>
> <name>extended</name>
> </ext>
>
> but i get:
> Caused by: org.apache.commons.configuration.ConfigurationRuntimeException:
> No ConfigurationProvider registered for tag name
> at org.apache.commons.configuration.DefaultConfigurationBuilder$ConfigurationBeanFactory.createBean(DefaultConfigurationBuilder.java:1293)
> at org.apache.commons.configuration.beanutils.BeanHelper.createBean(BeanHelper.java:336)
> ... 14 more
>
> Its a simple string so i am sure this should work out of the box,
> shouldnt it? I did not find any parameter like "datatype" which i
> could pass to the config element.
The problem is the <name> element. The XML file included by the
<configuration> element can only contain elements declaring other
configuration sources like <xml> or <properties>. (It must conform to
the same format as supported by DefaultConfigurationBuilder.) If you
want to give the included configuration a name, use this syntax:
<configuration>
<xml fileName="conf1extend.xml" config-name="conf1" />
</configuration>
Oliver
>
> Thanks for your help.
>
> Oli
>
> Am 19. April 2012 22:09 schrieb Oliver Heger<ol...@oliver-heger.de>:
>> Hi Oliver,
>>
>> Am 19.04.2012 16:05, schrieb Oliver Zemann:
>>
>>> Hi,
>>>
>>> just a short question:
>>> is it possible to include recursive all xml files that are referenced
>>> by any already included xml?
>>> eg.:
>>>
>>> root.xml:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <additional>
>>> <xml fileName="other.xml" config-name="another"/>
>>> </additional>
>>>
>>> other.xml:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xml fileName="other1.xml" config-name="another1"/>
>>> <xml fileName="other2.xml" config-name="another2"/>
>>> ...
>>>
>>> ?
>>>
>>> I tried it but they are simply ignored. Only the first recursion level
>>> (other.xml) is handled, all elements in other1.xml other2.xml ... are
>>> ignored.
>>> Can i somewhere put a recursive flag to the configuration?
>>> Thanks.
>>
>>
>> IIUC, the<configuration> element is the one you are looking for. You can
>> use it in a configuration definition file processed by
>> DefaultConfigurationBuilder to include another definition file. This works
>> recursively.
>>
>> So rather than using<xml> tags to include files, make use of
>> <configuration> elements. More details can be found in the user's guide [1].
>>
>> Oliver
>>
>> [1]
>> http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference
>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [configuration] recursive inclusion of xml files with fileNames tag
Posted by Oliver Zemann <ol...@googlemail.com>.
Hi Oliver ;)
Thanks for your help.
I tried it with the following code/config:
public static void main(String[] args) {
CombinedConfiguration conf = null;
try {
DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder(new File("conf/conf.xml"));
conf = builder.getConfiguration(true);
} catch (Exception ex) {
ex.printStackTrace();
}
Iterator<String> keys = conf.getKeys();
}
conf.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configuration fileName="conf1.xml" />
<configuration fileName="conf2.xml" />
<configuration fileName="conf3.xml" />
</configuration>
conf1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<conf1>
<name>conf1</name>
<xml fileName="conf1extend.xml" />
</conf1>
conf1extend.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ext>
<name>extended</name>
</ext>
but i get:
Caused by: org.apache.commons.configuration.ConfigurationRuntimeException:
No ConfigurationProvider registered for tag name
at org.apache.commons.configuration.DefaultConfigurationBuilder$ConfigurationBeanFactory.createBean(DefaultConfigurationBuilder.java:1293)
at org.apache.commons.configuration.beanutils.BeanHelper.createBean(BeanHelper.java:336)
... 14 more
Its a simple string so i am sure this should work out of the box,
shouldnt it? I did not find any parameter like "datatype" which i
could pass to the config element.
Thanks for your help.
Oli
Am 19. April 2012 22:09 schrieb Oliver Heger <ol...@oliver-heger.de>:
> Hi Oliver,
>
> Am 19.04.2012 16:05, schrieb Oliver Zemann:
>
>> Hi,
>>
>> just a short question:
>> is it possible to include recursive all xml files that are referenced
>> by any already included xml?
>> eg.:
>>
>> root.xml:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <additional>
>> <xml fileName="other.xml" config-name="another"/>
>> </additional>
>>
>> other.xml:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xml fileName="other1.xml" config-name="another1"/>
>> <xml fileName="other2.xml" config-name="another2"/>
>> ...
>>
>> ?
>>
>> I tried it but they are simply ignored. Only the first recursion level
>> (other.xml) is handled, all elements in other1.xml other2.xml ... are
>> ignored.
>> Can i somewhere put a recursive flag to the configuration?
>> Thanks.
>
>
> IIUC, the <configuration> element is the one you are looking for. You can
> use it in a configuration definition file processed by
> DefaultConfigurationBuilder to include another definition file. This works
> recursively.
>
> So rather than using <xml> tags to include files, make use of
> <configuration> elements. More details can be found in the user's guide [1].
>
> Oliver
>
> [1]
> http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference
>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [configuration] recursive inclusion of xml files with fileNames
tag
Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Oliver,
Am 19.04.2012 16:05, schrieb Oliver Zemann:
> Hi,
>
> just a short question:
> is it possible to include recursive all xml files that are referenced
> by any already included xml?
> eg.:
>
> root.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <additional>
> <xml fileName="other.xml" config-name="another"/>
> </additional>
>
> other.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <xml fileName="other1.xml" config-name="another1"/>
> <xml fileName="other2.xml" config-name="another2"/>
> ...
>
> ?
>
> I tried it but they are simply ignored. Only the first recursion level
> (other.xml) is handled, all elements in other1.xml other2.xml ... are
> ignored.
> Can i somewhere put a recursive flag to the configuration?
> Thanks.
IIUC, the <configuration> element is the one you are looking for. You
can use it in a configuration definition file processed by
DefaultConfigurationBuilder to include another definition file. This
works recursively.
So rather than using <xml> tags to include files, make use of
<configuration> elements. More details can be found in the user's guide [1].
Oliver
[1]
http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org