commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [configuration] Issue with combinedConfig from Factory
Date Tue, 01 Aug 2006 19:48:40 GMT
The problem is probably that ConfigurationFactory and 
CompositeConfiguration do not really work in a hierarchical manner and 
thus cannot cope with these hierarchical list structures.

The next release will contain an alternative class called 
DefaultConfigurationBuilder. This class works very similar to 
ConfigurationFactory, but provides true hierarchical processing.

There is already a release candidate available at [1]. You can find the 
documentation for this RC under [2]. The user's guide contains also a 
section about this class.

HTH
Oliver

[1] http://people.apache.org/~oheger/commons-configuration-1.3rc1/
[2] http://people.apache.org/~oheger/commons-configuration-1.3rc1/site/

thomas peter wrote:
> i once wrote something about this problem, but hadn't had the time to
> get back to this until now.
> 
> so here is an example:
> ------------<test.xml>---------------
> <root>
> 	<a>
> 		<b>a</b>
> 		<b>b</b>
> 		<b>c</b>
> 	</a>
> 	<a>
> 		<b>A</b>
> 		<b>B</b>
> 		<b>C</b>
> 		<b>D</b>
> 	</a>
> </root>
> ------------</test.xml>---------------
> ------------<test2.xml>---------------
> <root>
> 	<a>
> 		<b>1</b>
> 		<b>2</b>
> 		<b>3</b>
> 	</a>
> 	<a>
> 		<b>I</b>
> 		<b>II</b>
> 		<b>III</b>
> 		<b>IV</b>
> 	</a>
> </root>
> ------------</test2.xml>---------------
> ------------<config.xml>---------------
> <configuration>
>   <additional>
>     <xml fileName="test.xml" />
>     <xml fileName="test2.xml" />
>   </additional>
> </configuration>
> ------------</config.xml>---------------
> 
> and the java-code:
> 
> ConfigurationFactory factory = new ConfigurationFactory("config.xml");
> Configuration conf=null;
> try {
> 	conf = factory.getConfiguration();
> } catch (ConfigurationException e) {} catch(SecurityException secE){}
> for (int i=0;; i++){
> 	if(!conf.containsKey("a.b("+i+")")){
> 		break;
> 	}
> 	System.out.println(conf.getString("a.b("+i+")"));
> }
> 
> this outputs:
> 1
> 2
> 3
> IV
> 
> i'm sure i'm dooing something wrong, when i want to access every node
> and get  a result like
> 
> 1
> 2
> 3
> I
> II
> III
> IV
> a
> b
> c
> A
> B
> C
> D
> 
> what's wrong in my understanding?
> thank you in advance.
> cheers,
> thomas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


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