CODEFETCH™
            Examples
Cache of Javanut5Examples/Chapter5/Transform.java from
http://examples.oreilly.com/javanut5/Javanut5Examples.tar.gz
Source code below from:
Java In A Nutshell, 5th Edition
By David Flanagan
Published 15 March, 2005
Average rating

      Powells     Alibris


import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;

public class Transform {
    public static void main(String[] args)
        throws TransformerConfigurationException,
               TransformerException
    {
        // Get Source and Result objects for input, stylesheet, and output
        StreamSource input = new StreamSource(new File(args[0]));
        StreamSource stylesheet = new StreamSource(new File(args[1]));
        StreamResult output = new StreamResult(new File(args[2]));

        // Create a transformer and perform the transformation
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer = tf.newTransformer(stylesheet);
        transformer.transform(input, output);
    }
}