Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import java.io.Writer;

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

import org.w3c.dom.Document;

public class Main {
    public static void transformDocument(Document document, Writer out, File stylesheet)
            throws TransformerException {
        document.normalizeDocument();
        Transformer idTransform = null;
        TransformerFactory transFactory = TransformerFactory.newInstance();
        StreamSource stylesource = new StreamSource(stylesheet);
        idTransform = transFactory.newTransformer(stylesource);
        Source source = new DOMSource(document);
        Result result = new StreamResult(out);
        idTransform.transform(source, result);
    }
}