Java XML Transform createTransformer()

Here you can find the source of createTransformer()

Description

Creates a Transformer instance.

License

Open Source License

Exception

Parameter Description
Exception when error occurs

Return

the created Transformer

Declaration

public static Transformer createTransformer() throws Exception 

Method Source Code

//package com.java2s;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;

public class Main {
    /**/*from w ww  .  java2 s. co m*/
     * Creates a Transformer instance.
     *
     * @return the created Transformer
     * @throws Exception
     *             when error occurs
     */
    public static Transformer createTransformer() throws Exception {
        Transformer xmlTransformer = TransformerFactory.newInstance()
                .newTransformer();
        xmlTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
                "yes");
        xmlTransformer.setOutputProperty(OutputKeys.INDENT, "yes");

        return xmlTransformer;
    }
}

Related

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