0
所以我在設計一個基於某個DTD的XML文件。其中的邏輯是這樣的:DTD到XML錯誤
Category >> Books(can have many entries) >>Author[required], Price[required], Description, Image)
這裏是DTD產生:
<!ELEMENT CATAGORY (PRODUCT+)>
<!ELEMENT PRODUCT
(NAME,PRICE,DESCRIPTION*,PICTURE*)>
<!ATTLIST PRODUCT
NAME CDATA #REQUIRED
PRICE CDATA #REQUIRED
DESCRIPTION CDATA #IMPLIED
PICTURE CDATA #IMPLIED
CATEGORY (BOOKS|GADGETS|OTHERS) "BOOKS"
AUTHOR CDATA #REQUIRED
ISBN CDATA #IMPLIED
INVENTORY (InStock|Backordered|Discontinued) "InStock">
但是,我不能寫一個有效的XML。我這樣寫道:
<CATAGORY>
<PRODUCT NAME="XML BOOK" AUTHOR="XML GENIUS" CATEGORY="BOOKS" DESCRIPTION="BRILLIANT XML BOOK." INVENTORY="InStock" ISBN="653725327" PRICE="36.99" PICTURE=""/>
<PRODUCT NAME="XML MASTERS" AUTHOR="XML TEACHER" CATEGORY="BOOKS" DESCRIPTION="" INVENTORY="InStock" ISBN="" PICTURE="" PRICE="23.99"/>
</CATAGORY>
我得到以下錯誤。任何幫助表示讚賞。
Content model of element <PRODUCT> requires further child elements.
Error location: CATAGORY/PRODUCT
Details
VC: Element Valid (2): Content model of element <PRODUCT> requires further child elements.
您還沒有建模的子元素'NAME','PRICE',... – Boldewyn
@Boldewyn我真的很新的XML,你這是什麼意思模式?我想讓它們像一行文本一樣簡單,我需要添加更多內容?謝謝。 –
這意味着簡單地說,你說'PRODUCT'需要一個孩子'NAME',但是你從來沒有沿着<!ELEMENT NAME(#PCDATA)>定義一些東西。 – Boldewyn