(saxon dtd)java.net.SocketException:来自服务器的文件意外结束
我使用 Saxon(Java) 将 *.xhtml
转换为 *.xml
。
这是我的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);
因为*.xhtml
文件中有DTD,例如:
<!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映射到本地)?有什么例子吗?
谢谢。
I use Saxon(Java) to convert *.xhtml
to *.xml
.
Here is my java code:
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);
Because there is DTD in the *.xhtml
file, like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The error:
java.net.SocketException: Unexpected end of file from server
I want to know:
1) How to simply disable the dtd?
2) If not, how to set catalog file(mapping dtd to local) for saxon in Java program? Any example?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于知道如何实现了。
Finally, I know how to implement it.