[英]Why is the external DTD not validating to the XML file?
我需要外部DTD來驗證XML文件和'選擇''手機'和'手機'不斷出現錯誤。 我知道它與我的元素順序有關,但我無法弄明白。
我編輯了。 元素手機和手機,我相信它現在正在驗證
DTD
[
<!ELEMENT smartphones (choices+)>
<!ELEMENT choices (phones,phone,name,company,price,storage,description)>
<!ATTLIST choices phones NMTOKENS #REQUIRED>
<!ELEMENT phones (phone)>
<!ATTLIST phones CDATA #REQUIRED>
<!ELEMENT phone (name,company,price,storage,description)>
<!ATTLIST phone NMTOKENS #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT storage (#PCDATA)>
<!ELEMENT description (#PCDATA)>
]>
<!-- XML -->
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE smartphones SYSTEM "Vocab1DTD.dtd">
<smartphones>
<choices>Smart Phones
<phones>
<phone>
<name> </name>
<company> </company>
<price> </price>
<storage> </storage>
<description> </description>
</phone>
</phones>
</choices>
</smartphones>
這是一個更新的DTD,可以按原樣使用XML。
關於XML的小評論:將“智能手機”作為choices
文本並不是很有意義; 這可以通過smartphones
的孩子choices
來推斷。 此外, choices
和phones
似乎多余; 兩者的目的是什么?
如果您對我所做的更改有疑問,請與我們聯系。
Vocab1DTD.dtd
<!ELEMENT smartphones (choices+)>
<!ELEMENT choices (#PCDATA|phones)*>
<!ELEMENT phones (phone+)>
<!ELEMENT phone (name,company,price,storage,description)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT storage (#PCDATA)>
<!ELEMENT description (#PCDATA)>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.