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.
我如何“声明”一个实体进行解析?我如何才能预测所有潜在实体?
I'm parsing the the following...
<?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>
... using saxon9.jar, but got...
org.xml.sax.SAXParseException: The entity "ndash" was referenced, but not declared.
How do I "declare" an entity for a parse? How would I be able to anticipate all the potential entities?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在 DTD 中声明它。由于您使用的是外部 DTD,因此它必须为您声明。 tox.dtd 是否包含 ndash 的声明?
如果没有,您需要做一些受以下启发的事情:
例如,您可以使用定义 ndash 的标准 XHTML dtd 之一。
如果 tox.dtd 确实声明了它,那么您需要一个解析器来查找它。
You declare it in a DTD. Since you are using an external DTD, it has to declare it for you. Does tox.dtd contain a declaration for ndash?
If it does not, you need to do something inspired by:
You could use one of the standard XHTML dtds that defines ndash, for example.
If tox.dtd does declare it, then you need a resolver to find it.
我认为你应该使用 EntityResolver。
I think you should use EntityResolver.