Java XML Transform transformFile(Source stylesheetFile, File input, File output)

Here you can find the source of transformFile(Source stylesheetFile, File input, File output)

Description

transform File

License

Open Source License

Declaration

public static void transformFile(Source stylesheetFile, File input, File output) throws TransformerException 

Method Source Code


//package com.java2s;
/*/*from w  ww  . jav  a 2s  .c o m*/
 * Sonar C++ Plugin (Community)
 * Copyright (C) 2010-2017 SonarOpenCommunity
 * http://github.com/SonarOpenCommunity/sonar-cxx
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.io.File;

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class Main {
    public static void transformFile(Source stylesheetFile, File input, File output) throws TransformerException {
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(stylesheetFile);
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.transform(new StreamSource(input), new StreamResult(output));
    }
}

Related

  1. transform(Transformer transformer, Node element)
  2. transformar(String xmlOrigen, String xslOrigen)
  3. transformer()
  4. transformerExceptionMsg(TransformerException ex, Node contextNode, String str)
  5. transformerFactory()
  6. transformLogViaXSLT(String logFilePath, String xslFilePath)
  7. transformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration)
  8. transformStringToDoc(String input)
  9. transformStringToXMLGregorianCalendar(String dateTime, String pattern)