You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Chris Jensen <cj...@gmail.com> on 2005/01/21 06:03:25 UTC

[configuration] switching hierarchical elements

Hi,
I'm using a HierarchicalXMLConfiguration, is there a simple way to
switch the order of two elements.

Using the example from the XML howto at
http://jakarta.apache.org/commons/configuration/howto_xml.html
how could I change the order of table.table(0) and table.table(1) so
that table.table(0)[@tableType]="application"

Is it possible to do this in say two or three statements, or I do have
to iterate over all the subkeys and move them manually?

Thanks in advance
Chris

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


Re: [configuration] switching hierarchical elements

Posted by Emmanuel Bourg <eb...@apache.org>.
Chris Jensen wrote:

> In a nutshell, the Elements are being mapped to objects in a vector.
> eg
> <filter name="filter1">
>   <settings>
>      ...
>   </settings>
> </filter>
> <filter name="filter2">
>   <settings>
>      ...
>   </settings>
> </filter>
> 
> So the order that they appear is important, and the user may wish to
> reoder them.
> If that's not possible, then I guess I will have to just add an order
> attribute and change that, but it would've been more intuitive for
> people editing the file by hand if the elements appeared in order in
> the XML.

IMHO for such a use case I would use Digester/Betwixt instead of Commons 
Configuration. This will allow you to create Filter instances, reorder 
them as you want and then save them. Commons Configuration is designed 
for simple configuration purposes, not for higher level object 
serialization.

Emmanuel Bourg

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


Re: [configuration] switching hierarchical elements

Posted by Chris Jensen <cj...@gmail.com>.
> Such a feature is not supported at the moment. To be honest, it never
> occurred to me that switching element order could be useful. Could you
> perhaps tell a little more about your concrete use case?

In a nutshell, the Elements are being mapped to objects in a vector.
eg
<filter name="filter1">
  <settings>
     ...
  </settings>
</filter>
<filter name="filter2">
  <settings>
     ...
  </settings>
</filter>

So the order that they appear is important, and the user may wish to
reoder them.
If that's not possible, then I guess I will have to just add an order
attribute and change that, but it would've been more intuitive for
people editing the file by hand if the elements appeared in order in
the XML.

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


Re: [configuration] switching hierarchical elements

Posted by Oliver Heger <he...@med.uni-marburg.de>.
Such a feature is not supported at the moment. To be honest, it never 
occurred to me that switching element order could be useful. Could you 
perhaps tell a little more about your concrete use case?

What is planed for the future is to support other query languages, e.g. 
XPath. This would make it possible to access elements based on certain 
values of their attributes or sub elements, thus probably minimizing the 
need of changing element orders.

Oliver

Chris Jensen wrote:
> Hi,
> I'm using a HierarchicalXMLConfiguration, is there a simple way to
> switch the order of two elements.
> 
> Using the example from the XML howto at
> http://jakarta.apache.org/commons/configuration/howto_xml.html
> how could I change the order of table.table(0) and table.table(1) so
> that table.table(0)[@tableType]="application"
> 
> Is it possible to do this in say two or three statements, or I do have
> to iterate over all the subkeys and move them manually?
> 
> Thanks in advance
> Chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Dipl.-Inform. Oliver Heger
Zentrale Informationsverarbeitung (ZIV) / Bereich Anwenderverfahren
Klinikum der Philipps-Universität Marburg
Baldingerstraße,
D-35037 Marburg
Tel: +49 6421 28-66923
mailto:oliver.heger@med.uni-marburg.de

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