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.File; public class Transform { /** * Performes an XSLT transformation, taking an xml file as standard input * and sending the results to System.out. * First parameter is the name of the xsl file * other parameters are parameters names and values of the xsl file * adapted by Guy Lapalme from http://java.oreilly.com/news/javaxslt_0801.html */ public static void main(String[] args) throws Exception { if (args.length%2 != 1) { System.err.println( "Usage: java Transform xsl-file [param-name param-value]*"); System.exit(1); } File xsltFile = new File(args[0]); Source xmlSource = new StreamSource(System.in); Source xsltSource = new StreamSource(xsltFile); TransformerFactory transFact = TransformerFactory.newInstance(); Transformer trans = transFact.newTransformer(xsltSource); for(int i=1;i