代码之家  ›  专栏  ›  技术社区  ›  dacracot

org.xml.sax文件.SAXParseException:引用了实体“ndash”,但未声明

  •  3
  • dacracot  · 技术社区  · 15 年前

    <?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>
    

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

    如何为解析“声明”一个实体?我怎样才能预测所有潜在的实体?

    2 回复  |  直到 15 年前
        1
  •  1
  •   bmargulies    15 年前

    你在DTD中声明。由于您使用的是外部DTD,它必须为您声明它。做毒性试验包含ndash的声明?

    如果没有,你需要做一些受以下启发的事情:

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

    例如,您可以使用定义ndash的标准xhtmldtd之一。

        2
  •  0
  •   fospathi Eddie    5 年前

    我觉得你应该用 EntityResolver