Here you can find the source of newTransformer(boolean indented)
public static Transformer newTransformer(boolean indented)
//package com.java2s; //License from project: Apache License import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; public class Main { private static final Integer DEFAULT_INDENT = Integer.valueOf(4); public static Transformer newTransformer(boolean indented) { String indentFlag = (indented) ? "yes" : "no"; try {// w ww .j av a 2 s .c o m TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute("indent-number", DEFAULT_INDENT); Transformer transformer; transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.INDENT, indentFlag); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); return transformer; } catch (TransformerConfigurationException e) { throw new RuntimeException(e); } } }