Here you can find the source of formatXML(Transformer transformer)
Parameter | Description |
---|---|
transformer | - transformer that is used to process XML |
private static Transformer formatXML(Transformer transformer)
//package com.java2s; //License from project: Open Source License import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; public class Main { /**//from w w w. j av a2 s. c o m * This method formats the XML file by omitting the XML Declaration and * creating indentations * @param transformer - transformer that is used to process XML * @return a transformer that omits the XML declaration and performs indentations * @author Alex Song */ private static Transformer formatXML(Transformer transformer) { transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); return transformer; } }