1 17 18 package org.apache.tools.ant.taskdefs.optional; 19 20 import com.kvisco.xsl.XSLProcessor; 21 import com.kvisco.xsl.XSLReader; 22 import com.kvisco.xsl.XSLStylesheet; 23 import java.io.File ; 24 import java.io.FileOutputStream ; 25 import java.io.OutputStreamWriter ; 26 import org.apache.tools.ant.taskdefs.XSLTLiaison; 27 28 33 public class XslpLiaison implements XSLTLiaison { 34 35 protected XSLProcessor processor; 36 protected XSLStylesheet xslSheet; 37 38 public XslpLiaison() { 39 processor = new XSLProcessor(); 40 processor.getProperty("dummy-to-init-properties-map"); 45 } 46 47 public void setStylesheet(File fileName) throws Exception { 48 XSLReader xslReader = new XSLReader(); 49 xslSheet = xslReader.read(fileName.getAbsolutePath()); 52 } 53 54 public void transform(File infile, File outfile) throws Exception { 55 FileOutputStream fos = new FileOutputStream (outfile); 56 OutputStreamWriter out = new OutputStreamWriter (fos, "UTF8"); 58 processor.process(infile.getAbsolutePath(), xslSheet, out); 59 } 60 61 public void addParam(String name, String expression) { 62 processor.setProperty(name, expression); 63 } 64 65 } | Popular Tags |