Hi, My question is specifically on commons-configuration2.
I cannot seem to use XInclude within an XMLConfiguration file. Perhaps I
am doing something incorrectly, or perhaps it is unsupported, but I can't
seem to find documentation either way.
This is my example program, files and output.
TestConfiguration.java
package test;
import java.io.File;
import org.apache.commons.configuration2.ConfigurationUtils;
import org.apache.commons.configuration2.XMLConfiguration;
import
org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.ex.ConfigurationException;
public class TestConfiguration {
public static void main(String[] args) throws ConfigurationException {
Parameters params = new Parameters();
FileBasedConfigurationBuilder<XMLConfiguration> builder = new
FileBasedConfigurationBuilder<XMLConfiguration>(
XMLConfiguration.class);
builder.configure(params.fileBased().setFile(
new File("configs/test_external.xml")));
XMLConfiguration config = builder.getConfiguration();
System.out.println(ConfigurationUtils.toString(config));
}
}
configs/test_external.xml
<?xml version="1.0" encoding="UTF-8"?>
<ExternalRoot>
<ExternalElements>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="configs/test_internal.xml" />
</ExternalElements>
</ExternalRoot>
configs/test_internal.xml
<?xml version="1.0" encoding="UTF-8"?>
<InternalRoot>
<InternalElement name="1" />
<InternalElement name="2" />
<InternalElement name="3" />
</InternalRoot>
Result:
ExternalElements.xi:include[@xmlns:xi]=http://www.w3.org/2001/XInclude
ExternalElements.xi:include[@href]=configs/test_internal.xml
Expected Result:
ExternalElements.InternalRoot.InternalElement[@name]=1,2,3
Any help is appreciated!
Thanks,