这是代码
<?xml version = "1.0"?>
<!DOCTYPE addressbook [
<!ELEMENT addressbook (person*)>
<!ELEMENT person (familyname,firstname,city?,telephone+)>
<!ELEMENT familyname (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT telephone (#PCDATA)>
<!ATTLIST person id CDATA #REQUIRED>
<!ATTLIST telephone type CDATA #IMPLIED>
]>
<addressbook>
<person id="p01">
<familyname>De Niro</familyname>
<firstname>Roberto</firstname>
<city>Los Angeles</city>
<telephone type="mobile">123456</telephone>
</person>
<person id="p02">
<familyname>Bale</familyname>
<firstname>Gareth</firstname>
<city>Madrid</city>
<telephone>987654</telephone>
</person>
<person id="p03">
<familyname>Jobs</familyname>
<firstname>Steve</firstname>
<city>Palo Alto</city>
</person>
<person id="p04">
<familyname>Fry</familyname>
<firstname>Stephen</firstname>
<telephone type="landline">132867</telephone>
<telephone type="mobile">725282</telephone>
</person>
</addressbook>
答案 0 :(得分:1)
您的第三个<person>
元素没有电话号码:
<person id="p03">
<familyname>Jobs</familyname>
<firstname>Steve</firstname>
<city>Palo Alto</city>
</person>
但是,您的DTD需要一个或多个电话号码:
<!ELEMENT person (familyname,firstname,city?,telephone+)>
您需要为该<person>
元素添加电话号码,或更改内容模型以允许零个或多个电话号码:
<!ELEMENT person (familyname,firstname,city?,telephone*)>