1
我使用Saxon(Java)將*.xhtml
轉換爲*.xml
。(saxon dtd)java.net.SocketException:意外的服務器文件結尾
這裏是我的Java代碼:
System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
TransformerFactory tfactory = TransformerFactory.newInstance();
System.out.println("load xslt file");
Templates templates = tfactory.newTemplates(new StreamSource(xsltFile));
Transformer transformer = templates.newTransformer();
Result result = new StreamResult(new File(filtTempXml));
transformer.transform(new StreamSource(xmlFile), result);
因爲有DTD在*.xhtml
文件,如:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
錯誤:
java.net.SocketException: Unexpected end of file from server
我想知道:
1)如何簡單地禁用dtd? 2)如果不是,如何在Java程序中爲saxon設置目錄文件(映射dtd爲本地)?任何示例?
謝謝。
檢出http://stackoverflow.com/questions/1572808/java-xml-xslt-prevent-dtd-validation – alexbrn