You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "jo desmet (JIRA)" <ji...@apache.org> on 2011/04/06 14:57:05 UTC
[jira] [Updated] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
[ https://issues.apache.org/jira/browse/CONFIGURATION-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jo desmet updated CONFIGURATION-445:
------------------------------------
seems no attachement is possible, so inlined :
component1.xml :
<configuration>
<key1 override="USER">value1</key1>
<key2 override="USER2">value2</key2>
</configuration>
component1_spec.xml:
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
AttributeTest.java (relevant section)
@Test
public void testAttributeSave() throws Exception {
final XMLConfiguration x1 = new XMLConfiguration("component1.xml");
final XMLConfiguration x2 = new XMLConfiguration("component1_spec.xml");
dump(x1);
dump(x2);
final CombinedConfiguration c = new CombinedConfiguration();
c.setNodeCombiner(new OverrideCombiner());
c.addConfiguration(x2);
dump(c);
c.addConfiguration(x1);
dump(c);
}
public static void dump(final XMLConfiguration c) throws ConfigurationException {
final StringWriter w = new StringWriter();
c.save(w);
LOGGER.info(w.toString());
}
public static void dump(final CombinedConfiguration c) throws ConfigurationException {
final XMLConfiguration dump = new XMLConfiguration(c);
dump(dump);
}
and resulting output (Last section is where the output is : the attribute is moved to top level):
14:41:53.704 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key1 override="USER">value1</key1>
<key2 override="USER2">value2</key2>
</configuration>
14:41:53.704 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
14:41:53.720 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
14:41:53.720 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration override="USER2">
<key2>value2_spec</key2>
<key1 override="USER">value1</key1>
</configuration>
> XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
> ---------------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-445
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: jo desmet
>
> when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
> So when saving this configuration the attributes get lost and attached to the rootnode.
> I made a unit test and will attach the following files :
> - component1.xml
> - component1_spec.xml
> - AttributeTest.java
> - log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira