You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/11/15 11:08:34 UTC
DO NOT REPLY [Bug 32240] New: -
XMLConfiguration::save() does not keep element hierarchy
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32240>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32240
Summary: XMLConfiguration::save() does not keep element hierarchy
Product: Commons
Version: 1.0 Final
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Configuration
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: Christian.Kemmer@viadee.de
I am using commons.configuration.XMLConfiguration to save some configuration
elements of my Java 1.4.2 application in a file. If I use nested elements in my
configuration, this structure is not mapped to the saved XML-File.
As an example, consider the following simple main method:
public static void main(String[] args) {
try {
XMLConfiguration myXMLConfig = new XMLConfiguration();
myXMLConfig.setProperty("A","valueA");
myXMLConfig.setProperty("A.B","valueA.B");
myXMLConfig.setProperty("A.B.C.D","valueA.B.C.D");
myXMLConfig.setProperty("E.F.G.H","valueE.F.G.H");
myXMLConfig.setProperty("I.J.K.L","valueI.J.K.L");
myXMLConfig.setProperty("I.J.K",null);
myXMLConfig.setProperty("I.J",null);
myXMLConfig.setProperty("I",null);
myXMLConfig.save("testConfig.xml");
} catch (ConfigurationException e) {
System.out.println("ERROR: " + e.toString());
}
}
What I expect to get by executing this piece of code is the following (modulo
formatting issues, of course):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<A> valueA
<B> valueB
<C>
<D> valueD
</D>
</C>
</B>
</A>
<E>
<F>
<G>
<H> valueE.F.G.H
</H>
</G>
</F>
</E>
<I> null
<J> null
<K> null
<L> valueI.J.K.L
</L>
</K>
</J>
</I>
</configuration>
The null-values in I.J.K and so on have only been introduced to show that such a
workarund does not work, either.
What I actually receive by storing testConfig.xml is the following:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<A>valueA<B>valueA.B<D>valueA.B.C.D</D>
</B>
</A>
<H>valueE.F.G.H</H>
<L>valueI.J.K.L</L>
<K>null</K>
<J>null</J>
<I>null</I>
</configuration>
In my opinion, at least two failures can be seen above:
a) The elements I, J, K, and L are not nested, but all declared on top level of
the XML-document
b) Elements without any value are not automatically inserted as, e.g., element
C for the path A.B.C.D or elements E, F, and G for E.F.G.H
I also tried to use HierarchicalXMLConfiguration, but corresponding objects can
not be saved:
ERROR: org.apache.commons.configuration.ConfigurationException: Can't save
HierarchicalXMLConfigurations
I am using the final Version 1.0 (not RC1 nor RC2) JAR-Files provied by
http://jakarta.apache.org/commons/configuration/downloads.html
Best regards,
Christian Kemmer
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org