I am trying to migrate from the old commons-configuration to commons-configuration2 but I am having trouble formatting the XML output with indentation when using the new Configurations builder.
Before I did like this, which worked fine.
XMLConfiguration configuration = new XMLConfiguration()
{
@Override
protected Transformer createTransformer()
throws ConfigurationException
{
Transformer transformer = super.createTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("http://xml.apache.org/xslt}indent-amount", "4");
return transformer;
}
};
But in commons-configurations2 you use a ConfigurationBuilder to get a XMLConfiguration instance, which removes the ability to create a subclass of XMLConfiguration, for example like this:
XMLConfiguration configuration = configurations
.xmlBuilder(new File("config.xml"))
.getConfiguration();
Is there any other way of customizing the XMLConfiguration's Transformer?
Thanks!