62,615
社区成员
发帖
与我相关
我的任务
分享
/**
*
* @param xslName xsl转换器文件
* @param inputFileName 需要转换的文件
* @param outFile 转换后的输出文件
* @throws Exception
*/
public static void xhtmlToFo(String xslName, String inputFileName ,String outFile) throws Exception {
TransformerFactory tFactory = TransformerFactory.newInstance();
//用指定的XSLT样式单文件创建一个转换器
Transformer transformer = tFactory.newTransformer(new StreamSource( Thread.currentThread().getContextClassLoader().getResourceAsStream( xslName)));
//执行转换,并将转换后的目标文档作为响应输出
transformer.transform(new StreamSource( new FileInputStream(new File(inputFileName))),
new StreamResult(new FileOutputStream(new File(outFile))));
}