Here you can find the source of getTransformer(Source xsltSource)
Parameter | Description |
---|---|
xsltSource | the xslt source |
Parameter | Description |
---|---|
TransformerFactoryConfigurationError | the transformer factory configuration error |
TransformerConfigurationException | the transformer configuration exception |
public static Transformer getTransformer(Source xsltSource) throws TransformerFactoryConfigurationError, TransformerConfigurationException
//package com.java2s; /**// w w w.j av a 2s . c o m * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.stream.StreamSource; public class Main { /** The Constant TRANSFORMER_FACTORY. */ private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); /** * Gets a new instance from a Transformer object. * * @param xsltSource * the xslt source * @return the transformer * @throws TransformerFactoryConfigurationError * the transformer factory configuration error * @throws TransformerConfigurationException * the transformer configuration exception */ public static Transformer getTransformer(Source xsltSource) throws TransformerFactoryConfigurationError, TransformerConfigurationException { return TRANSFORMER_FACTORY.newTransformer(xsltSource); } /** * Gets the transformer. * * @param xsltFile * the xslt file * @return the transformer * @throws TransformerFactoryConfigurationError * the transformer factory configuration error * @throws TransformerConfigurationException * the transformer configuration exception */ public static Transformer getTransformer(File xsltFile) throws TransformerFactoryConfigurationError, TransformerConfigurationException { return getTransformer(new StreamSource(xsltFile)); } /** * Gets the transformer. * * @param xsltInputFile * the xslt input file * @return the transformer * @throws TransformerFactoryConfigurationError * the transformer factory configuration error * @throws TransformerConfigurationException * the transformer configuration exception */ public static Transformer getTransformer(String xsltInputFile) throws TransformerFactoryConfigurationError, TransformerConfigurationException { return getTransformer(new File(xsltInputFile)); } }