Commit 0fec6bc3 authored by 李秀明's avatar 李秀明

fix: XSLT Injection(XSLT注入)

parent 478d6450
...@@ -8,6 +8,7 @@ import org.apache.poi.hwpf.converter.WordToHtmlConverter; ...@@ -8,6 +8,7 @@ import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
...@@ -25,8 +26,8 @@ import java.net.URLConnection; ...@@ -25,8 +26,8 @@ import java.net.URLConnection;
public class WordConverterUtils { public class WordConverterUtils {
public static MultipartFile fileToMultipartFile(File file) { public static MultipartFile fileToMultipartFile(File file) {
FileItem fileItem = createFileItem(file); FileItem fileItem = createFileItem(file);
MultipartFile multipartFile = new CommonsMultipartFile(fileItem); MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
...@@ -48,26 +49,26 @@ public class WordConverterUtils { ...@@ -48,26 +49,26 @@ public class WordConverterUtils {
} }
return item; return item;
} }
/** /**
* word文档转html文档 * word文档转html文档
* *
* @param srcFile 原文档 * @param srcFile 原文档
* @param targetFile 目标文档 * @param targetFile 目标文档
* @param fileService 图片上传接口 * @param fileService 图片上传接口
*/ */
public static void wordToHtml(String srcFile, String targetFile, String imagePathStr,String readUrl,FileService fileService,String product,String appKey,String token ) { public static void wordToHtml(String srcFile, String targetFile, String imagePathStr,String readUrl,FileService fileService,String product,String appKey,String token ) {
File html = new File(targetFile); File html = new File(targetFile);
if ( html.exists()) { if ( html.exists()) {
return; return;
} else { } else {
if (srcFile.endsWith(".doc")) { if (srcFile.endsWith(".doc")) {
docToHtml( imagePathStr,readUrl,srcFile, html, fileService, product, appKey, token); docToHtml( imagePathStr,readUrl,srcFile, html, fileService, product, appKey, token);
} }
// else if (srcFile.endsWith(".docx")) { // else if (srcFile.endsWith(".docx")) {
// docxToHtml( imagePathStr,readUrl,srcFile, html, fileService, product, appKey, token); // docxToHtml( imagePathStr,readUrl,srcFile, html, fileService, product, appKey, token);
// } // }
...@@ -76,7 +77,7 @@ public class WordConverterUtils { ...@@ -76,7 +77,7 @@ public class WordConverterUtils {
/** /**
* .doc文档转换成html * .doc文档转换成html
* *
* @param srcFile 原文档 * @param srcFile 原文档
* @param targetFile 目标文档 * @param targetFile 目标文档
* @param fileService 图片上传接口 * @param fileService 图片上传接口
...@@ -87,7 +88,7 @@ public class WordConverterUtils { ...@@ -87,7 +88,7 @@ public class WordConverterUtils {
File imagePath = new File(imagePathStr); File imagePath = new File(imagePathStr);
if (!imagePath.exists()) { if (!imagePath.exists()) {
imagePath.mkdirs(); imagePath.mkdirs();
} }
URL url = new URL(srcFile); URL url = new URL(srcFile);
//链接url //链接url
URLConnection uc = url.openConnection(); URLConnection uc = url.openConnection();
...@@ -117,6 +118,7 @@ public class WordConverterUtils { ...@@ -117,6 +118,7 @@ public class WordConverterUtils {
DOMSource domSource = new DOMSource(htmlDocument); DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(targetFile); StreamResult streamResult = new StreamResult(targetFile);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
...@@ -145,27 +147,27 @@ public class WordConverterUtils { ...@@ -145,27 +147,27 @@ public class WordConverterUtils {
// * @param fileService 图片上传接口 // * @param fileService 图片上传接口
// */ // */
// private static void docxToHtml( String imagePathStr,String readUrl,String srcFile, File targetFile, FileService fileService,String product,String appKey,String token) { // private static void docxToHtml( String imagePathStr,String readUrl,String srcFile, File targetFile, FileService fileService,String product,String appKey,String token) {
// //
// File imagePath = new File(imagePathStr); // File imagePath = new File(imagePathStr);
// if (!imagePath.exists()) { // if (!imagePath.exists()) {
// imagePath.mkdirs(); // imagePath.mkdirs();
// } // }
// OutputStream outputStreamWriter=null; // OutputStream outputStreamWriter=null;
// try { // try {
// //
// URL url = new URL(srcFile); // URL url = new URL(srcFile);
// //链接url // //链接url
// URLConnection uc = url.openConnection(); // URLConnection uc = url.openConnection();
// //获取输入流 // //获取输入流
// InputStream in = uc.getInputStream(); // InputStream in = uc.getInputStream();
// XWPFDocument document = new XWPFDocument(in); // XWPFDocument document = new XWPFDocument(in);
// //存储图片 // //存储图片
// PdfOptions options=PdfOptions.create(); // PdfOptions options=PdfOptions.create();
// //
// outputStreamWriter=new FileOutputStream(targetFile); // outputStreamWriter=new FileOutputStream(targetFile);
// PdfConverter.getInstance().convert(document,outputStreamWriter,options); // PdfConverter.getInstance().convert(document,outputStreamWriter,options);
// //
// //
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } finally { // } finally {
...@@ -176,8 +178,8 @@ public class WordConverterUtils { ...@@ -176,8 +178,8 @@ public class WordConverterUtils {
// } catch (Exception e2) { // } catch (Exception e2) {
// e2.printStackTrace(); // e2.printStackTrace();
// } // }
// //
// } // }
// //
// } // }
} }
...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter; ...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter;
import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions; import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
...@@ -104,6 +105,7 @@ public class WordConverterUtils { ...@@ -104,6 +105,7 @@ public class WordConverterUtils {
DOMSource domSource = new DOMSource(htmlDocument); DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(targetFile); StreamResult streamResult = new StreamResult(targetFile);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
...@@ -150,6 +152,7 @@ public class WordConverterUtils { ...@@ -150,6 +152,7 @@ public class WordConverterUtils {
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter); StreamResult streamResult = new StreamResult(stringWriter);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml { ...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml {
/** /**
* 将doc文档转换为html文件 * 将doc文档转换为html文件
* *
* @param is 需要转换的doc文件 * @param is 需要转换的doc文件
* @param outPutFile 输出html文件的全路径 * @param outPutFile 输出html文件的全路径
* @throws TransformerException * @throws TransformerException
...@@ -119,6 +120,7 @@ public class WordHtml implements AbstractHtml { ...@@ -119,6 +120,7 @@ public class WordHtml implements AbstractHtml {
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -191,8 +193,8 @@ public class WordHtml implements AbstractHtml { ...@@ -191,8 +193,8 @@ public class WordHtml implements AbstractHtml {
} }
} }
} }
public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){ public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){
FileInputStream fis= null; FileInputStream fis= null;
FileInputStream fis1= null; FileInputStream fis1= null;
...@@ -209,7 +211,9 @@ public class WordHtml implements AbstractHtml { ...@@ -209,7 +211,9 @@ public class WordHtml implements AbstractHtml {
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result=new StreamResult(stm); Result result=new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer=TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer=transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
...@@ -8,6 +8,7 @@ import org.apache.poi.hssf.converter.ExcelToHtmlConverter; ...@@ -8,6 +8,7 @@ import org.apache.poi.hssf.converter.ExcelToHtmlConverter;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
...@@ -72,6 +73,7 @@ public class ExcelHtml implements AbstractHtml { ...@@ -72,6 +73,7 @@ public class ExcelHtml implements AbstractHtml {
StreamResult streamResult = new StreamResult(out); StreamResult streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "GB2312"); serializer.setOutputProperty(OutputKeys.ENCODING, "GB2312");
serializer.setOutputProperty(OutputKeys.INDENT, "no"); serializer.setOutputProperty(OutputKeys.INDENT, "no");
......
...@@ -31,6 +31,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile; ...@@ -31,6 +31,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
...@@ -159,6 +160,7 @@ public class WordHtml implements AbstractHtml { ...@@ -159,6 +160,7 @@ public class WordHtml implements AbstractHtml {
out = new ByteArrayOutputStream(); out = new ByteArrayOutputStream();
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
......
...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter; ...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter;
import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions; import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
...@@ -103,6 +104,7 @@ public class WordConverterUtils { ...@@ -103,6 +104,7 @@ public class WordConverterUtils {
DOMSource domSource = new DOMSource(htmlDocument); DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(targetFile); StreamResult streamResult = new StreamResult(targetFile);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
...@@ -149,6 +151,7 @@ public class WordConverterUtils { ...@@ -149,6 +151,7 @@ public class WordConverterUtils {
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter); StreamResult streamResult = new StreamResult(stringWriter);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -78,6 +79,7 @@ public class WordHtml implements AbstractHtml { ...@@ -78,6 +79,7 @@ public class WordHtml implements AbstractHtml {
out = new ByteArrayOutputStream(); out = new ByteArrayOutputStream();
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -161,7 +163,9 @@ public class WordHtml implements AbstractHtml { ...@@ -161,7 +163,9 @@ public class WordHtml implements AbstractHtml {
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result = new StreamResult(stm); Result result = new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer = TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter; ...@@ -6,6 +6,7 @@ import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter;
import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions; import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
...@@ -104,6 +105,7 @@ public class WordConverterUtils { ...@@ -104,6 +105,7 @@ public class WordConverterUtils {
DOMSource domSource = new DOMSource(htmlDocument); DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(targetFile); StreamResult streamResult = new StreamResult(targetFile);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
...@@ -150,6 +152,7 @@ public class WordConverterUtils { ...@@ -150,6 +152,7 @@ public class WordConverterUtils {
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter); StreamResult streamResult = new StreamResult(stringWriter);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty(OutputKeys.INDENT, "yes");
......
...@@ -29,6 +29,7 @@ import org.w3c.dom.Document; ...@@ -29,6 +29,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Text; import org.w3c.dom.Text;
import javax.xml.XMLConstants;
import javax.xml.transform.OutputKeys; import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
...@@ -46,7 +47,7 @@ import static org.apache.poi.hwpf.converter.AbstractWordUtils.TWIPS_PER_INCH; ...@@ -46,7 +47,7 @@ import static org.apache.poi.hwpf.converter.AbstractWordUtils.TWIPS_PER_INCH;
* This implementation doesn't create images or links to them. This can be * This implementation doesn't create images or links to them. This can be
* changed by overriding {@link #processImage(Element, boolean, Picture)} * changed by overriding {@link #processImage(Element, boolean, Picture)}
* method. * method.
* *
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com) * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/ */
@Beta @Beta
...@@ -71,7 +72,7 @@ public class WordToHtmlConverter extends AbstractWordConverter ...@@ -71,7 +72,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
private static final POILogger logger = POILogFactory private static final POILogger logger = POILogFactory
.getLogger( WordToHtmlConverter.class ); .getLogger( WordToHtmlConverter.class );
private static String getSectionStyle( Section section ) private static String getSectionStyle( Section section )
{ {
float leftMargin = section.getMarginLeft() / TWIPS_PER_INCH; float leftMargin = section.getMarginLeft() / TWIPS_PER_INCH;
...@@ -101,7 +102,7 @@ public class WordToHtmlConverter extends AbstractWordConverter ...@@ -101,7 +102,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
/** /**
* Java main() interface to interact with {@link WordToHtmlConverter} * Java main() interface to interact with {@link WordToHtmlConverter}
* *
* <p> * <p>
* Usage: WordToHtmlConverter infile outfile * Usage: WordToHtmlConverter infile outfile
* </p> * </p>
...@@ -126,6 +127,7 @@ public class WordToHtmlConverter extends AbstractWordConverter ...@@ -126,6 +127,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
StreamResult streamResult = new StreamResult( new File(args[1]) ); StreamResult streamResult = new StreamResult( new File(args[1]) );
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
// TODO set encoding from a command argument // TODO set encoding from a command argument
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" ); serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
...@@ -153,7 +155,7 @@ public class WordToHtmlConverter extends AbstractWordConverter ...@@ -153,7 +155,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
/** /**
* Creates new instance of {@link WordToHtmlConverter}. Can be used for * Creates new instance of {@link WordToHtmlConverter}. Can be used for
* output several {@link HWPFDocument}s into single HTML document. * output several {@link HWPFDocument}s into single HTML document.
* *
* @param document * @param document
* XML DOM Document used as HTML document * XML DOM Document used as HTML document
*/ */
...@@ -577,7 +579,7 @@ public class WordToHtmlConverter extends AbstractWordConverter ...@@ -577,7 +579,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
if(paragraph.getStyleIndex()>0){ if(paragraph.getStyleIndex()>0){
pElement.setAttribute("id", "p"+System.nanoTime()%100000000+"-"+paragraph.getStyleIndex()); pElement.setAttribute("id", "p"+System.nanoTime()%100000000+"-"+paragraph.getStyleIndex());
} }
WordToHtmlUtils.compactSpans( pElement ); WordToHtmlUtils.compactSpans( pElement );
return; return;
} }
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml { ...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml {
/** /**
* 将doc文档转换为html文件 * 将doc文档转换为html文件
* *
* @param fileName 需要转换的doc文件 * @param fileName 需要转换的doc文件
* @param outPutFile 输出html文件的全路径 * @param outPutFile 输出html文件的全路径
* @throws TransformerException * @throws TransformerException
...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml { ...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml {
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml { ...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml {
} }
} }
} }
public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){ public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){
FileInputStream fis= null; FileInputStream fis= null;
FileInputStream fis1= null; FileInputStream fis1= null;
...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml { ...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml {
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result=new StreamResult(stm); Result result=new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer=TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer= transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
...@@ -40,6 +40,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -40,6 +40,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -387,7 +388,9 @@ public class CheckController extends AbstractBaseController { ...@@ -387,7 +388,9 @@ public class CheckController extends AbstractBaseController {
} }
Result result = new StreamResult(html); Result result = new StreamResult(html);
Transformer transformer = TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
......
...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -194,7 +195,9 @@ public class TaskController extends AbstractBaseController{ ...@@ -194,7 +195,9 @@ public class TaskController extends AbstractBaseController{
} }
Result result=new StreamResult(html); Result result=new StreamResult(html);
Transformer transformer =TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
File htmlFile = new File(html); File htmlFile = new File(html);
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml { ...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml {
/** /**
* 将doc文档转换为html文件 * 将doc文档转换为html文件
* *
* @param fileName 需要转换的doc文件 * @param fileName 需要转换的doc文件
* @param outPutFile 输出html文件的全路径 * @param outPutFile 输出html文件的全路径
* @throws TransformerException * @throws TransformerException
...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml { ...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml {
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml { ...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml {
} }
} }
} }
public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){ public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){
FileInputStream fis= null; FileInputStream fis= null;
FileInputStream fis1= null; FileInputStream fis1= null;
...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml { ...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml {
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result=new StreamResult(stm); Result result=new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer=TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer= transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
...@@ -48,6 +48,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -48,6 +48,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -869,7 +870,9 @@ public class CheckController extends AbstractBaseController { ...@@ -869,7 +870,9 @@ public class CheckController extends AbstractBaseController {
} }
Result result = new StreamResult(html); Result result = new StreamResult(html);
Transformer transformer = TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
......
...@@ -40,6 +40,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -40,6 +40,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -195,7 +196,9 @@ public class TaskController extends AbstractBaseController{ ...@@ -195,7 +196,9 @@ public class TaskController extends AbstractBaseController{
} }
Result result=new StreamResult(html); Result result=new StreamResult(html);
Transformer transformer =TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
File htmlFile = new File(html); File htmlFile = new File(html);
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml { ...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml {
/** /**
* 将doc文档转换为html文件 * 将doc文档转换为html文件
* *
* @param fileName 需要转换的doc文件 * @param fileName 需要转换的doc文件
* @param outPutFile 输出html文件的全路径 * @param outPutFile 输出html文件的全路径
* @throws TransformerException * @throws TransformerException
...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml { ...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml {
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml { ...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml {
} }
} }
} }
public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){ public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){
FileInputStream fis= null; FileInputStream fis= null;
FileInputStream fis1= null; FileInputStream fis1= null;
...@@ -204,11 +206,13 @@ public class WordHtml implements AbstractHtml { ...@@ -204,11 +206,13 @@ public class WordHtml implements AbstractHtml {
fis1 = new FileInputStream(xsltPath); fis1 = new FileInputStream(xsltPath);
Source template=new StreamSource(fis1); Source template=new StreamSource(fis1);
PrintStream stm=new PrintStream(new File(hrmlPath)); PrintStream stm=new PrintStream(hrmlPath);
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result=new StreamResult(stm); Result result=new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer=TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer= transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
...@@ -46,6 +46,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -46,6 +46,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -420,7 +421,9 @@ public class CheckController extends AbstractBaseController { ...@@ -420,7 +421,9 @@ public class CheckController extends AbstractBaseController {
} }
Result result = new StreamResult(html); Result result = new StreamResult(html);
Transformer transformer = TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
......
...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.XMLConstants;
import javax.xml.transform.*; import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
...@@ -193,9 +194,11 @@ public class TaskController extends AbstractBaseController{ ...@@ -193,9 +194,11 @@ public class TaskController extends AbstractBaseController{
dirFile.mkdirs(); dirFile.mkdirs();
} }
Result result=new StreamResult(html); Result result = new StreamResult(html);
Transformer transformer =TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer.transform(source, result); transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result);
File htmlFile = new File(html); File htmlFile = new File(html);
FileInputStream fis = new FileInputStream(htmlFile); FileInputStream fis = new FileInputStream(htmlFile);
......
...@@ -15,6 +15,7 @@ import org.slf4j.Logger; ...@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml { ...@@ -69,7 +70,7 @@ public class WordHtml implements AbstractHtml {
/** /**
* 将doc文档转换为html文件 * 将doc文档转换为html文件
* *
* @param fileName 需要转换的doc文件 * @param fileName 需要转换的doc文件
* @param outPutFile 输出html文件的全路径 * @param outPutFile 输出html文件的全路径
* @throws TransformerException * @throws TransformerException
...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml { ...@@ -118,6 +119,7 @@ public class WordHtml implements AbstractHtml {
streamResult = new StreamResult(out); streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。 // 创建执行从 Source 到 Result 的复制的新 Transformer。
Transformer serializer = tf.newTransformer(); Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式 serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 文件编码方式
...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml { ...@@ -190,8 +192,8 @@ public class WordHtml implements AbstractHtml {
} }
} }
} }
public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){ public static void xml2Ttml(String docPath, String xsltPath, String hrmlPath){
FileInputStream fis= null; FileInputStream fis= null;
FileInputStream fis1= null; FileInputStream fis1= null;
...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml { ...@@ -208,7 +210,9 @@ public class WordHtml implements AbstractHtml {
//讲转换后的结果输出到 stm 中即 F:\123.html //讲转换后的结果输出到 stm 中即 F:\123.html
Result result=new StreamResult(stm); Result result=new StreamResult(stm);
//根据XSL文件创建准个转换对象 //根据XSL文件创建准个转换对象
Transformer transformer=TransformerFactory.newInstance().newTransformer(template); TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer= transformerFactory.newTransformer(template);
//处理xml进行交换 //处理xml进行交换
transformer.transform(source, result); transformer.transform(source, result);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment