Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.InputStream;
import java.io.OutputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class Main {
    public static void transform(InputStream xslis, InputStream xmlis, OutputStream xmlos) {
        try {
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new StreamSource(xslis));
            transformer.transform(new StreamSource(xmlis), new StreamResult(xmlos));
            xslis.close();
            xmlis.close();
            xmlos.close();
        } catch (Exception e) {
            throw new RuntimeException("Fail to do XSLT transformation", e);
        }
    }
}