我正在做一项任务,并得到了我的结果,但它似乎忘了在我的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)>
谢谢!