private Transformer getTransformerConfiguredWithIndentation() throws TransformerConfigurationException { final Transformer transformer = TransformerFactoryImpl.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); return transformer; }