Here you can find the source of getTransformer()
private static Transformer getTransformer() throws TransformerConfigurationException
//package com.java2s; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; public class Main { private static TransformerFactory transformerFactory = null; private static Transformer getTransformer() throws TransformerConfigurationException { return getTransformerFactory().newTransformer(); }//from w ww.j a v a 2 s . c o m private static synchronized TransformerFactory getTransformerFactory() { if (transformerFactory == null) transformerFactory = TransformerFactory.newInstance(); return transformerFactory; } }