[
https://issues.apache.org/jira/browse/CONFIGURATION-373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oliver Heger updated CONFIGURATION-373:
---------------------------------------
Description:
{code}
addProperty("profiles.profile.name", "QAL");
addProperty("profiles.profile(-1).name", "PROD"); // <- index (-1)
to create a NEW branch
// see:
http://commons.apache.org/configuration/userguide/howto_xml.html#Hierarchical_properties
- "Adding new properties"
{code}
should create a config like (XML view):
{code:xml}
<configuration>
<profiles>
<profile>
<name>QAL</name>
</profile>
<profile>
<name>PROD</name>
</profile>
</profiles>
</configuration>
{code}
but it does this:
{code:xml}
<configuration>
<profiles>
<profile>
<name>QAL</name>
<- QAL and PROD
<name>PROD</name>
<- in the same branch !
</profile>
</profiles>
</configuration>
{code}
Test program:
{code}
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
public class Main {
public void doit(String[] args) throws
ConfigurationException{
HierarchicalConfiguration hc=new
HierarchicalConfiguration();
hc.addProperty("profiles.profile.name", "QAL");
hc.addProperty("profiles.profile(-1).name", "PROD");
XMLConfiguration x1=new
XMLConfiguration();
x1.append(hc);
x1.save("conf.xml");
System.exit(0);
}
public static void main(String[] args) throws ConfigurationException {
Main main = new Main();
main.doit(args);
}
}
{code}
was:
addProperty("profiles.profile.name", "QAL");
addProperty("profiles.profile(-1).name", "PROD");
<- index (-1) to create a NEW branch
// see:
http://commons.apache.org/configuration/userguide/howto_xml.html#Hierarchical_properties
- "Adding new properties"
should create a config like (XML view):
<configuration>
<profiles>
<profile>
<name>QAL</name>
</profile>
<profile>
<name>PROD</name>
</profile>
</profiles>
</configuration>
but it does this:
<configuration>
<profiles>
<profile>
<name>QAL</name>
<- QAL and PROD
<name>PROD</name>
<- in the same branch !
</profile>
</profiles>
</configuration>
Test program:
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
public class Main {
public void doit(String[] args) throws
ConfigurationException{
HierarchicalConfiguration hc=new
HierarchicalConfiguration();
hc.addProperty("profiles.profile.name", "QAL");
hc.addProperty("profiles.profile(-1).name", "PROD");
XMLConfiguration x1=new
XMLConfiguration();
x1.append(hc);
x1.save("conf.xml");
System.exit(0);
}
public static void main(String[] args) throws ConfigurationException {
Main main = new Main();
main.doit(args);
}
}
Improved formatting
> HierarchicalConfiguration: adding a new branch using index (-1) does not work
> -----------------------------------------------------------------------------
>
> Key: CONFIGURATION-373
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-373
> Project: Commons Configuration
> Issue Type: Bug
> Components: Expression engine
> Affects Versions: 1.6
> Environment: W2003, JDK 1.6
> Reporter: Antoine Morpain
>
> {code}
> addProperty("profiles.profile.name", "QAL");
> addProperty("profiles.profile(-1).name", "PROD"); // <- index (-1)
> to create a NEW branch
> // see:
> http://commons.apache.org/configuration/userguide/howto_xml.html#Hierarchical_properties
> - "Adding new properties"
> {code}
> should create a config like (XML view):
> {code:xml}
> <configuration>
> <profiles>
> <profile>
> <name>QAL</name>
> </profile>
> <profile>
> <name>PROD</name>
> </profile>
> </profiles>
> </configuration>
> {code}
> but it does this:
> {code:xml}
> <configuration>
> <profiles>
> <profile>
> <name>QAL</name>
> <- QAL and PROD
> <name>PROD</name>
> <- in the same branch !
> </profile>
> </profiles>
> </configuration>
> {code}
> Test program:
> {code}
> import org.apache.commons.configuration.ConfigurationException;
> import org.apache.commons.configuration.HierarchicalConfiguration;
> import org.apache.commons.configuration.XMLConfiguration;
> public class Main {
> public void doit(String[] args) throws
> ConfigurationException{
> HierarchicalConfiguration
> hc=new HierarchicalConfiguration();
>
> hc.addProperty("profiles.profile.name", "QAL");
>
> hc.addProperty("profiles.profile(-1).name", "PROD");
> XMLConfiguration x1=new
> XMLConfiguration();
> x1.append(hc);
> x1.save("conf.xml");
> System.exit(0);
> }
>
> public static void main(String[] args) throws ConfigurationException {
> Main main = new Main();
> main.doit(args);
> }
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.