【发布时间】:2016-07-14 00:16:34
【问题描述】:
下面是具有 dtd 模式的 XML,但它不验证,为什么? 我在 Eclipse 和http://www.xmlvalidation.com/index.php?id=1&L=0 中检查了它:
<?xml version="1.0"?>
<!DOCTYPE person-list [
<!ELEMENT person-list (person*)>
<!ELEMENT person (first-name,second-name?,last-name,index-no,birth-date)>
<!ELEMENT first-name (#PCDATA)>
<!ELEMENT second-name (#PCDATA)>
<!ELEMENT last-name (#PCDATA)>
<!ELEMENT index-no (#PCDATA)>
<!ELEMENT birth-date (#PCDATA)>
<!ATTLIST person id ID #REQUIRED>
]>
<person-list>
<person id="1">
<first-name>ds</first-name>
<second-name>asd</second-name>
<last-name>asd</last-name>
<index-no>34</index-no>
<birth-date>1915-01-01</birth-date>
</person>
<person id="2">
<first-name>dfswsf</first-name>
<last-name>sdfsdf</last-name>
<index-no>23</index-no>
<birth-date>1916-02-02</birth-date>
</person>
</person-list>
【问题讨论】:
-
您的 id 属性不符合 id 属性的规则
标签: xml