无法解析 JavaHelp 的 toc.xml
我为 JavaHelp 的 toc.xml
文件编写了一个 XML 解析器,以便拦截我在 tocitem
标记中使用的一些被 JavaHelp 忽略的属性。 toc.xml
如下所示:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE toc
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 2.0//EN"
"http://java.sun.com/products/javahelp/toc_2_0.dtd">
<toc version="2.0">
<tocitem text="Introduction" target="intro" action="myapp.help.introAction"/>
</toc>
我正在使用标准 SAX 解析器解析 toc.xml
。当我解析文件时,出现以下异常:
myapp.help.TOCTreeFactory[WARN]: Failed to load TOC file from 'jar:file:/home/samad/myapp.jar!/workflow-help/toc.xml'
Caused by:
http://java.sun.com/javase/technologies/desktop/javahelp/toc_2_0.dtd
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at myapp.help.TOCTreeFactory.createTree(TOCTreeFactory.java:43)
...
我打开了 URL http://java.sun.com/javase/technologies/desktop/javahelp/toc_2_0.dtd
,并得到404.
如何解决这个问题?我尝试下载 JavaHelp 发行版,但它不包含 SAX 所需的 toc_2_0.dtd
文件。
I wrote an XML parser for JavaHelp's toc.xml
file in order to intercept some attributes I use in the tocitem
tag that are ignored by JavaHelp. Here's what toc.xml
looks like:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE toc
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 2.0//EN"
"http://java.sun.com/products/javahelp/toc_2_0.dtd">
<toc version="2.0">
<tocitem text="Introduction" target="intro" action="myapp.help.introAction"/>
</toc>
I am parsing toc.xml
using the standard SAX parser. When I parse the file, I get the following exception:
myapp.help.TOCTreeFactory[WARN]: Failed to load TOC file from 'jar:file:/home/samad/myapp.jar!/workflow-help/toc.xml'
Caused by:
http://java.sun.com/javase/technologies/desktop/javahelp/toc_2_0.dtd
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at myapp.help.TOCTreeFactory.createTree(TOCTreeFactory.java:43)
...
I opened up the URL http://java.sun.com/javase/technologies/desktop/javahelp/toc_2_0.dtd
, and I get a 404.
How can I resolve this problem? I tried downloading the JavaHelp distribution, but it doesn't contain the toc_2_0.dtd
file that is needed by SAX.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过在工厂关闭验证?
另一种选择...停止你的下载 DTD 的 Java SAX 解析器
Have you tried turning off validation in the factory?
One other alternative...Stop your Java SAX parser from downloading DTDs
在寻找类似问题的解决方案时,我首先想到了这个问题。
setValidating()
方法对我来说也不起作用。 此答案相关问题 向我指出 SAXParserFactory 的setFeature()
方法,确实有效。When searching for solutions to a similar issue, I was first directed to this question. The
setValidating()
method didn't work for me either. This answer to a related question pointed me toward SAXParserFactory'ssetFeature()
method, which did work.