1 51 package org.apache.fop.tools.xslt; 52 53 import java.io.*; 54 import javax.xml.transform.TransformerFactory ; 55 import javax.xml.transform.stream.StreamSource ; 56 import javax.xml.transform.stream.StreamResult ; 57 import javax.xml.transform.dom.DOMSource ; 58 import javax.xml.transform.dom.DOMResult ; 59 60 public class XSLTransform { 61 62 public static void transform(String xmlSource, String xslURL, 63 String outputFile) throws Exception { 64 71 TransformerFactory.newInstance().newTransformer( 72 new StreamSource (xslURL)).transform( 73 new StreamSource (xmlSource),new StreamResult (new File(outputFile))); 74 } 75 76 public static void transform(org.w3c.dom.Document xmlSource, 77 String xslURL, 78 String outputFile) throws Exception { 79 88 TransformerFactory.newInstance().newTransformer( 89 new StreamSource (xslURL)).transform( 90 new DOMSource (xmlSource),new StreamResult (new File(outputFile))); 91 } 92 93 public static void transform(String xmlSource, String xslURL, 94 Writer outputWriter) throws Exception { 95 103 TransformerFactory.newInstance().newTransformer( 104 new StreamSource (xslURL)).transform( 105 new StreamSource (xmlSource),new StreamResult (outputWriter)); 106 } 107 108 public static void transform(org.w3c.dom.Document xmlSource, 109 InputStream xsl, 110 org.w3c.dom.Document outputDoc) throws Exception { 111 120 TransformerFactory.newInstance().newTransformer( 121 new StreamSource (xsl)).transform( 122 new DOMSource (xmlSource),new DOMResult (outputDoc)); 123 } 124 125 194 } 195 | Popular Tags |