MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;
import java.util.Properties;

import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class MainClass {
    public static void main(String argv[]) throws Exception {
        Properties props = System.getProperties();
        props.put("javax.xml.transform.TransformerFactory", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
        System.setProperties(props);
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Templates translet = tFactory.newTemplates(new StreamSource("OrderProcessing.xslt"));

        Transformer transformer = translet.newTransformer();

        transformer.transform(new StreamSource("CustomerOrders.xml"),
                new StreamResult(new FileOutputStream("SortedOrders.html")));

        transformer.transform(new StreamSource("CustomerOrders1.xml"),
                new StreamResult(new FileOutputStream("SortedOrders1.html")));

    }
}