Java XML Transform createTransformer()

Here you can find the source of createTransformer()

Description

Create a Transformer just the way we like it.

License

Open Source License

Return

Returns a new .

Declaration

private static Transformer createTransformer() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.xml.transform.*;

public class Main {
    private static final TransformerFactory m_xformFactory = TransformerFactory.newInstance();

    /**//www.  j  a va2 s  . co  m
     * Create a {@link Transformer} just the way we like it.
     *
     * @return Returns a new {@link Transformer}.
     */
    private static Transformer createTransformer() {
        final Transformer xform;
        try {
            xform = m_xformFactory.newTransformer();
        } catch (TransformerConfigurationException e) {
            throw new IllegalStateException(e);
        }
        xform.setOutputProperty(OutputKeys.INDENT, "yes");
        xform.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
        xform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        return xform;
    }
}

Related

  1. createOutputTransformer(String encoding, boolean omitXmlDeclaration, boolean indent, int indentAmount)
  2. createPrettyTransformer(int indent)
  3. createTransformer()
  4. createTransformer()
  5. createTransformer()
  6. createTransformer(final File xsltFile)
  7. createTransformerHandler(int indent)
  8. createTXT(Transformer xf, Node doc)
  9. exceptionToString(TransformerException exception, boolean showSystemId)