Org.xml.sax.SAXParseException: "ndash" object was referenced but not declared

I make out 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   &ndash; Thu Feb 25, 4:54 pm ET&lt;br&gt;&lt;br&gt;NEW YORK (Reuters) &ndash; Nothing happened today."/>
<tox:parameter value="10245"/>
</tox:model>
</tox:message>

... using saxon9.jar, but got it ...

org.xml.sax.SAXParseException: The entity "ndash" was referenced, but not declared.

How can I β€œdeclare” an entity for parsing? How can I foresee all potential objects?

+3
source share
2 answers

You declare it in DTD. Since you are using an external DTD, it should declare it for you. Does tox.dtd have an ad for ndash?

If this is not the case, you need to do something inspired by:

<!DOCTYPE foo [
    <!ENTITY % MathML SYSTEM "http://www.example.com/MathML.dtd">
    %MathML;
    <!ENTITY % SpeechML SYSTEM "http://www.example.com/SpeechML.dtd">
    %SpeechML;
]>

You can use one of the standard XHTML dtds that defines ndash, for example.

If tox.dtd announces this, you need a recognizer to find it.

+1

Source: https://habr.com/ru/post/1736227/


All Articles