我爲JavaHelp的toc.xml
文件編寫了一個XML解析器,以攔截我在tocitem
標記中使用的一些屬性,這些屬性被JavaHelp忽略。這裏是toc.xml
樣子:無法解析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
文件。
調用setValidating沒有幫助,但鏈接幫助。 – Horcrux7 2010-12-02 09:03:12