import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import java.io.*; public class Transform { /** * Performes an XSLT transformation, sending the results * to System.out. */ public static void main(String[] args) throws Exception { if (args.length != 2) { System.err.println( "Usage: java Transform [xmlfile] [xsltfile]"); System.exit(1); } File xmlFile = new File(args[0]); File xsltFile = new File(args[1]); Source xmlSource = new StreamSource(xmlFile); Source xsltSource = new StreamSource(xsltFile); TransformerFactory transFact = TransformerFactory.newInstance(); Transformer trans = transFact.newTransformer(xsltSource); trans.transform(xmlSource, new StreamResult(System.out)); } }