Reputation: 217
in my xml:
<mother>
<name>mary</name>
<child>
<name>Ali</name>
</child>
</mother>
so in my dtd:
<!ELEMENT mother (name,child)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT child (name)>
<!ELEMENT name(#PCDATA)>
when i try to run the DTD, its said that my name already been declared. so how i should change in order to solve this problem?
Upvotes: 1
Views: 663
Reputation: 23637
You don't need the second name
declaration. These three declarations:
<!ELEMENT mother (name,child)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT child (name)>
are sufficient to validate your file. Your DTD "says":
<mother>
element must contain a sequence of one <name>
, followed by one <child>
<name>
element can contain parsed character data (any text, including nothing, but no tags)<child>
element must contain exactly one <name>
Upvotes: 1