// Set up streams for input, stylesheet, and output.
// These do not have to come from or go to files. We can also use the
// javax.xml.transform.{dom,sax} packages use DOM trees and streams of
// SAX events as sources and sinks for documents and stylesheets.
StreamSource input = new StreamSource(new File(args[0]));
StreamSource stylesheet = new StreamSource(new File(args[1]));
StreamResult output = new StreamResult(new File(args[2]));
// Get a factory object, create a Transformer from it, and
// transform the input document to the output document.
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(stylesheet);
transformer.transform(input, output);