Here you can find the source of createIndentingTransformer()
public static Transformer createIndentingTransformer()
//package com.java2s; //License from project: Open Source License import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; public class Main { private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory .newInstance();/*w ww . j a v a 2 s.c o m*/ /** * @return a transformer that indents entries by 4 characters (never null) */ public static Transformer createIndentingTransformer() { Transformer transformer; try { TRANSFORMER_FACTORY.setAttribute("indent-number", 4); transformer = TRANSFORMER_FACTORY.newTransformer(); } catch (final Exception e) { throw new IllegalStateException(e); } transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "4"); return transformer; } }