Java XML Transform getTransformer()

Here you can find the source of getTransformer()

Description

get Transformer

License

Open Source License

Exception

Parameter Description
TransformerConfigurationException if no TransformerFactory can be located in theruntime environment.

Return

a new XSLT transformer

Declaration

public static Transformer getTransformer() throws TransformerConfigurationException 

Method Source Code

//package com.java2s;
/*//from  w w  w  . j  a  v a 2  s.c  o  m
 * $Id$
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;

public class Main {
    public static final String TRANSFORMER_FACTORY_JDK5 = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";

    /**
     * @return a new XSLT transformer
     * @throws TransformerConfigurationException if no TransformerFactory can be located in the
     * runtime environment.
     */
    public static Transformer getTransformer() throws TransformerConfigurationException {
        TransformerFactory tf;
        try {
            tf = TransformerFactory.newInstance();
        } catch (TransformerFactoryConfigurationError e) {
            System.setProperty("javax.xml.transform.TransformerFactory", TRANSFORMER_FACTORY_JDK5);
            tf = TransformerFactory.newInstance();
        }
        if (tf != null) {
            return tf.newTransformer();
        } else {
            throw new TransformerConfigurationException("Unable to instantiate a TransformerFactory");
        }
    }
}

Related

  1. getTransformedText(File doc, File xsl, Object[] params)
  2. getTransformer()
  3. getTransformer()
  4. getTransformer()
  5. getTransformer()
  6. getTransformer()
  7. getTransformer()
  8. getTransformer(boolean omitXmlDeclaration, String xslURL)
  9. getTransformer(boolean standalone, boolean indent, int indentNumber, boolean omitXmlDeclaration)