1 23 24 package com.sun.enterprise.config.serverbeans.validation; 25 26 import javax.xml.transform.TransformerFactory ; 27 import javax.xml.transform.sax.SAXSource ; 28 import javax.xml.transform.Source ; 29 import javax.xml.transform.Transformer ; 30 import org.xml.sax.InputSource ; 31 import java.io.FileReader ; 32 import javax.xml.transform.Result ; 33 import javax.xml.transform.stream.StreamSource ; 34 import javax.xml.transform.stream.StreamResult ; 35 import java.io.File ; 36 37 38 39 public class SimpleTransform 40 { 41 public static void main(String [] args) throws Exception { 42 String in = null; 43 String xsl = null; 44 String out = null; 45 46 if (args.length != 6){ 47 System.err.println("Insufficient args: SimpleTransform -in file -xsl file -out file"); 48 System.exit(1); 49 } 50 51 for (int i = 0; i < args.length; i++){ 52 if (args[i].equals("-in")){ 53 in = args[++i]; 54 } else if (args[i].equals("-xsl")){ 55 xsl = args[++i]; 56 } else if (args[i].equals("-out")){ 57 out = args[++i]; 58 } else { 59 System.err.println("Unrecognized arg: "+args[i]); 60 System.exit(1); 61 } 62 } 63 64 65 final TransformerFactory f = TransformerFactory.newInstance(); 66 final Transformer t = f.newTransformer(new StreamSource (new File (xsl))); 67 final Source src = new SAXSource (new VariableResolver(), 70 new InputSource (in)); 71 final Result res = new StreamResult (out); 72 73 t.transform(src, res); 74 } 75 76 77 } 78 | Popular Tags |