You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Thorsten Lampe <ka...@yahoo.de> on 2007/12/19 09:47:39 UTC

Adding nodes in an XMLConfiguration, but not at the end

Is there any way of adding a piece of configuration (i.e. an element) not to the END of a list as can be done with something like
(cp. website examples)


// Add new table "tasks" with name element and type attribute

config.addProperty("tables table/name", "tasks");



but rather IN BETWEEN two existing elements? I've got the following sub configuration:



  <Clusters>

    <Cluster>

      <Name>MyCluster1</Name>

      <URL>http://something.org</URL>

    </Cluster>

    <Cluster>

       <Name>MyCluster3</Name>

       <URL>http://anotherthing.org</URL>

    </Cluster>

   </Clusters>



Now I have to programatically add another cluster configuration in between the existing clusters "MyCluster1" and "MyCluster3". Any ideas how this can be achieved using 
commons configuration or is this not supported at all? I really did not find any way of doing this!

Thanks for any help,


Thorsten





       __________________________________ Ihr erstes Fernweh? Wo gibt es den schönsten Strand? www.yahoo.de/clever

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


RE: Adding nodes in an XMLConfiguration, but not at the end

Posted by Wes Clark <wc...@guidewire.com>.
Do you control the XSD?  Add an attribute to the Cluster such as
clusterNum or something if the ordering is important.

<Cluster clusternum="2"> ....

What does the order matter anyway?

-----Original Message-----
From: Oliver Heger [mailto:oliver.heger@oliver-heger.de] 
Sent: Wednesday, December 19, 2007 9:33 AM
To: Jakarta Commons Users List
Subject: Re: Adding nodes in an XMLConfiguration, but not at the end

Thorsten Lampe wrote:
> Is there any way of adding a piece of configuration (i.e. an element)
not to the END of a list as can be done with something like
> (cp. website examples)
> 
> 
> // Add new table "tasks" with name element and type attribute
> 
> config.addProperty("tables table/name", "tasks");
> 
> 
> 
> but rather IN BETWEEN two existing elements? I've got the following
sub configuration:
> 
> 
> 
>   <Clusters>
> 
>     <Cluster>
> 
>       <Name>MyCluster1</Name>
> 
>       <URL>http://something.org</URL>
> 
>     </Cluster>
> 
>     <Cluster>
> 
>        <Name>MyCluster3</Name>
> 
>        <URL>http://anotherthing.org</URL>
> 
>     </Cluster>
> 
>    </Clusters>
> 
> 
> 
> Now I have to programatically add another cluster configuration in
between the existing clusters "MyCluster1" and "MyCluster3". Any ideas
how this can be achieved using 
> commons configuration or is this not supported at all? I really did
not find any way of doing this!
> 
> Thanks for any help,
> 
> 
> Thorsten
> 
There does not seem to be a trivial way to achieve this with the 
existing API. This feature has never been requested so far.

Maybe the concept of an order is somewhat unusual when dealing with 
configuration settings? You normally only are interested whether a 
property exists and what its value is. Java's preferences API for 
instance does not support ordered properties either. What you want, 
seems to be more in the domain of XML processing.

Oliver

---------------------------------------------------------------------
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: Adding nodes in an XMLConfiguration, but not at the end

Posted by Oliver Heger <ol...@oliver-heger.de>.
Thorsten Lampe wrote:
> Is there any way of adding a piece of configuration (i.e. an element) not to the END of a list as can be done with something like
> (cp. website examples)
> 
> 
> // Add new table "tasks" with name element and type attribute
> 
> config.addProperty("tables table/name", "tasks");
> 
> 
> 
> but rather IN BETWEEN two existing elements? I've got the following sub configuration:
> 
> 
> 
>   <Clusters>
> 
>     <Cluster>
> 
>       <Name>MyCluster1</Name>
> 
>       <URL>http://something.org</URL>
> 
>     </Cluster>
> 
>     <Cluster>
> 
>        <Name>MyCluster3</Name>
> 
>        <URL>http://anotherthing.org</URL>
> 
>     </Cluster>
> 
>    </Clusters>
> 
> 
> 
> Now I have to programatically add another cluster configuration in between the existing clusters "MyCluster1" and "MyCluster3". Any ideas how this can be achieved using 
> commons configuration or is this not supported at all? I really did not find any way of doing this!
> 
> Thanks for any help,
> 
> 
> Thorsten
> 
There does not seem to be a trivial way to achieve this with the 
existing API. This feature has never been requested so far.

Maybe the concept of an order is somewhat unusual when dealing with 
configuration settings? You normally only are interested whether a 
property exists and what its value is. Java's preferences API for 
instance does not support ordered properties either. What you want, 
seems to be more in the domain of XML processing.

Oliver

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