1 21 22 package nu.xom.samples; 23 24 import nu.xom.Builder; 25 import nu.xom.Document; 26 import nu.xom.Nodes; 27 import nu.xom.xslt.XSLTransform; 28 29 34 public class Transformer { 35 36 46 public static void main(String [] args) { 47 48 if (args.length < 2) { 49 System.err.println( 50 "Usage: java nu.xom.samples.Transformer document stylesheet" 51 ); 52 return; 53 } 54 55 System.setProperty( 56 "javax.xml.transform.TransformerFactory", 57 "org.apache.xalan.processor.TransformerFactoryImpl"); 58 61 62 Builder builder = new Builder(); 63 try { 64 Document doc = builder.build(args[0]); 65 Document stylesheet = builder.build(args[1]); 66 XSLTransform transform = new XSLTransform(stylesheet); 67 68 Nodes output = transform.transform(doc); 69 70 for (int i = 0; i < output.size(); i++) { 71 System.out.print(output.get(i).toXML()); 72 } 73 System.out.println(); 74 } 75 catch (Exception ex) { 76 System.err.println(ex); 77 ex.printStackTrace(); 78 } 79 80 } 81 82 } 83 | Popular Tags |