Here you can find the source of createTransformer(final File xsltFile)
static Transformer createTransformer(final File xsltFile) throws TransformerException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.Collections; import java.util.Map; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; public class Main { static Transformer createTransformer(final File xsltFile) throws TransformerException { return createTransformer(xsltFile, Collections.<String, String> emptyMap()); }/*from w ww .j a v a 2 s. c o m*/ /** * @param xsltFile The XSLT stylesheet file * @param parms XSL parameters to pass to the stylesheet. * @return the configured XSLT transformer * @throws TransformerException if there is a problem configuring the transformer */ static Transformer createTransformer(final File xsltFile, final Map<String, String> parms) throws TransformerException { try { Source xslSource = new StreamSource(xsltFile); TransformerFactory transFact = TransformerFactory.newInstance(); transFact.setAttribute("indent-number", 2); Transformer transformer = transFact.newTransformer(xslSource); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); for (String parm : parms.keySet()) { transformer.setParameter(parm, parms.get(parm)); } return transformer; } catch (TransformerConfigurationException e) { e.printStackTrace(); throw e; } } }