1 23 24 package org.dbforms.devgui; 25 26 import org.dbforms.util.Util; 27 28 import java.io.File ; 29 import java.io.FileNotFoundException ; 30 31 import java.io.FileOutputStream ; 33 import java.io.IOException ; 34 35 import javax.xml.transform.OutputKeys ; 36 import javax.xml.transform.Transformer ; 37 import javax.xml.transform.TransformerConfigurationException ; 38 import javax.xml.transform.TransformerException ; 39 40 import javax.xml.transform.TransformerFactory ; 42 import javax.xml.transform.stream.StreamResult ; 43 import javax.xml.transform.stream.StreamSource ; 44 45 46 47 50 public class XSLTransformer { 51 65 public static void transform(File xmlFile, 66 File xslFile, 67 File destinationFile, 68 boolean useJsCalendar, 69 String xsltEncoding) 70 throws TransformerException , 71 TransformerConfigurationException , 72 FileNotFoundException , IOException { 73 TransformerFactory tFactory = TransformerFactory.newInstance(); 78 79 Transformer transformer = tFactory.newTransformer(new StreamSource (xslFile)); 83 84 if (!Util.isNull(xsltEncoding)) { 86 transformer.setOutputProperty(OutputKeys.ENCODING, xsltEncoding); 87 } 88 89 if (useJsCalendar) { 92 transformer.setParameter("useCalendar", "true"); 93 } 94 95 transformer.transform(new StreamSource (xmlFile), 98 new StreamResult (new FileOutputStream (destinationFile))); 99 } 100 } 101 | Popular Tags |