org.xml.sax.SAXParseException:实体 “ndash的” 被引用,但没有宣布
问题描述:
我解析了下面......org.xml.sax.SAXParseException:实体 “ndash的” 被引用,但没有宣布
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tox:message SYSTEM "http://tox.sf.net/tox/dtd/tox.dtd">
<tox:message xmlns:tox="http://tox.sourceforge.net/">
<tox:model owner="scott" package="queue" function="appendFact">
<tox:parameter value=" By John Smith – Thu Feb 25, 4:54 pm ET<br><br>NEW YORK (Reuters) – Nothing happened today."/>
<tox:parameter value="10245"/>
</tox:model>
</tox:message>
...使用saxon9.jar,但得到。 ..
org.xml.sax.SAXParseException: The entity "ndash" was referenced, but not declared.
如何“声明”一个实体进行解析?我将如何能够预测所有潜在的实体?
答
您在DTD声明。由于您正在使用外部DTD,因此必须为您申报。 tox.dtd是否包含ndash声明?
如果没有,你需要做一些启发:
<!DOCTYPE foo [
<!ENTITY % MathML SYSTEM "http://www.example.com/MathML.dtd">
%MathML;
<!ENTITY % SpeechML SYSTEM "http://www.example.com/SpeechML.dtd">
%SpeechML;
]>
你可以使用标准的XHTML的DTD定义ndash的,例如之一。
如果tox.dtd声明了它,那么你需要一个解析器来找到它。