我正在做一項任務,並得到了我的結果,但它似乎忘了在我的DTD文件中聲明元素。我是否聲明所有元素或者只是包含額外信息的元素?如果我不清楚,這裏是從我的任務的摘錄:如何聲明DTD元素?
<entry id= 'c01'>
<MetaTags>Business</MetaTags>
<title><brand>HP Pavilion</brand><name>550-112NA</name></title>
<Desciption>While other towers have been standing still, HP has revolutionized the category. From magnified performance and reliability, to its stylish redesign, this HP Pavilion is the best thing to happen to towers in over 20 years.</Desciption>
<Price>€579</Price>
<Image src ="Image1.jpg"/>
<Specs>
<CPU>A10-8750 APU</CPU>
<GPU>Radeon R7</GPU>
<RAM>8 GB DDR3</RAM>
<Storage><HDD> 2TB </HDD><SSD></SSD></Storage>
<OS>Windows 10</OS>
<optional>
<Monitor>LG 22" Full HD TV</Monitor>
<Keyboard>Microsoft Wired Keyboard 600</Keyboard>
<Mouse>Logitech M705 Mouse</Mouse>
</optional>
</Specs>
</entry>
請問標籤條目都需要申報,但是沒有其他的元素會因爲他們沒有額外的變量?
如果這是正確的,將申報是這樣的:
<!ATTLIST entry id CDATA #REQUIRED>
我希望我做清楚我的問題,因爲我是新來XML.Here是我的DTD,如果你需要看到的是,如果我還做錯了什麼。謝謝!
<!ELEMENT ComputerShop (entry+)>
<!ELEMENT entry (MetaTags, title, Description, Price, Image, Specs)>
<!ELEMENT MetaTags (#PCDATA)>
<!ELEMENT Description (#PCDATA)>
<!ELEMENT Price (#PCDATA)>
<!ELEMENT Image (#PCDATA)>
<!ELEMENT title (brand, name)>
<!ELEMENT brand (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT Specs (CPU, GPU, RAM, Storage, OS, optional)>
<!ELEMENT CPU (#PCDATA)>
<!ELEMENT GPU (#PCDATA)>
<!ELEMENT RAM (#PCDATA)>
<!ELEMENT Storage (HDD | SSD)>
<!ELEMENT OS (#PCDATA)>
<!ELEMENT optional (Monitor | Keyboard | Mouse>
<!ELEMENT Monitor (#PCDATA)>
<!ELEMENT Keyboard (#PCDATA)>
<!ELEMENT Mouse (#PCDATA)>
謝謝!