Java XML Transform getTransformer(StreamSource streamSource)

Here you can find the source of getTransformer(StreamSource streamSource)

Description

get Transformer

License

Apache License

Declaration

public static Transformer getTransformer(StreamSource streamSource) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;

public class Main {
    public static Transformer getTransformer(StreamSource streamSource) {
        // setup the xslt transformer
        System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");

        //net.sf.saxon.TransformerFactoryImpl impl = new net.sf.saxon.TransformerFactoryImpl();
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = null;
        try {/*from  w  w w  .j  av a  2  s .c om*/
            if (streamSource != null) {
                transformer = tFactory.newTransformer(streamSource);
            } else {
                transformer = tFactory.newTransformer();
            }
            //return impl.newTransformer(streamSource);
            return transformer;
        } catch (TransformerConfigurationException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getTransformer()
  2. getTransformer(boolean omitXmlDeclaration, String xslURL)
  3. getTransformer(boolean standalone, boolean indent, int indentNumber, boolean omitXmlDeclaration)
  4. getTransformer(final InputStream xsl)
  5. getTransformer(Source xsltSource)
  6. getTransformerFactory()
  7. getTransformerFactory()
  8. getTransformerFactory()
  9. getTransformerFactory()