我正在尝试解析下面显示的XML文件:
<?xml version="1.0"?>
<!DOCTYPE COUNTRIES_CONTINENT PUBLIC
"-//XYZ//DTD Declarations(CountriesContinent)//EN" "dtds/countries_continent.dtd">
<COUNTRIES_CONTINENT>
<CONTINENT id="6" name="Oceania" value="12">
<COUNTRY name="Argentina"/>
<COUNTRY name="Bolivia"/>
<COUNTRY name="Brazil"/>
<COUNTRY name="Chile"/>
<COUNTRY name="Colombia"/>
<COUNTRY name="Ecuador"/>
<COUNTRY name="Guyana"/>
<COUNTRY name="Paraguay"/>
<COUNTRY name="Peru"/>
<COUNTRY name="Suriname"/>
<COUNTRY name="Uruguay"/>
<COUNTRY name="Venezuela"/>
</CONTINENT>
</COUNTRIES_CONTINENT>
拥有以下DTD文件:
<!ELEMENT COUNTRIES_CONTINENT (CONTINENT+)>
<!ELEMENT CONTINENT (COUNTRY+)>
<!ELEMENT COUNTRY EMPTY>
<!ATTLIST CONTINENT id CDATA ID #REQUIRED>
<!ATTLIST CONTINENT name CDATA #REQUIRED>
<!ATTLIST CONTINENT value CDATA #REQUIRED>
<!ATTLIST COUNTRY name CDATA #REQUIRED>
我收到以下异常:
Open quote is expected for the attribute "id" associated with an element type "CONTINENT".
有谁可以指出出了什么问题?
答案 0 :(得分:2)
<!ATTLIST CONTINENT id CDATA ID #REQUIRED>
属性类型可以是CDATA
或ID
,但不能同时属于两者。这些类型中的每一种都有自己的规则,描述了允许它们包含的值的范围。请检查id
的预期类型。