XML解析错误:文档类型声明包含或指向的标记声明必须格式正确

时间:2016-06-26 17:28:55

标签: java xml saxparseexception

我有一个XML文档,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE IMPORTANT_DAYS PUBLIC "-//XYZ//DTD Declarations(ImportantDays)//EN" "dtds/important_days.dtd">
<IMPORTANT_DAYS>
    <MONTH name="January">
        <DAY    date="9"    occassion="NRI Day"/>
        <DAY    date="10"   occassion="World Laughter Day"/>
        <DAY    date="12"   occassion="National Youth Day"/>
        <DAY    date="15"   occassion="Army Day"/>
        <DAY    date="25"   occassion="National Tourism Day"/>
        <DAY    date="26"   occassion="Republic Day Of India;International Customs Day"/>
        <DAY    date="30"   occassion="Martyr's Day;World Leprosy Day"/>
    </MONTH>
</IMPORTANT_DAYS>

以下DTD文件名为-important_days.dtd:

<!ELEMENT IMPORTANT_DAYS (MONTH+)>
<!ELEMENT MONTH (DAY+)>
<!ELEMENT DAY EMPTY>
<!ATTLIST MONTH name NMTOKEN #REQUIRED>
<!ATTLIST DAY date NMTOKEN #IMPLIED>
<!ATTlIST DAY count NMTOKEN #IMPLIED>
<!ATTlIST DAY day NMTOKEN #IMPLIED>
<!ATTLIST DAY occassion CDATA #REQUIRED>

当我尝试解析XML文件时,我在“important_days.dtd”的第6行收到以下错误:

6:The markup declarations contained or pointed to by the document type declaration must be well-formed.

有谁可以指出问题是什么?

1 个答案:

答案 0 :(得分:2)

XML区分大小写。请注意小写的L字符,它们应该是大写的:

Line 6: <!ATTlIST DAY count NMTOKEN #IMPLIED>
             ^

Line 7: <!ATTlIST DAY day NMTOKEN #IMPLIED>
             ^