Does anyone know if there is a generic way to set the indent-amount on a transformer? I'm guessing the property below is specific to apache transformers. I believe we're using an apache transformer by default, but what if the default changes in the future? Is there a way to identify which transformer you're using and set an appropriate custom property?
TransformerFactory tf = TransformerFactory.newInstance();
if (tf.getFeature(SAXTransformerFactory.FEATURE) == false) {
throw new CISException(ErrorCodes.SAX_TRANSFORMER, "");
}
SAXTransformerFactory stf = (SAXTransformerFactory)tf;
TransformerHandler hd = stf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
return hd;