Hello!
This is a totally newbie DTD question. Let's say that I have the following XML:
Here is my first swing at the DTD:
In English: My root node must have only 1 person element. The person element must have a name element and may have a pets element. The pets element must have one or more pet elements. The pet element has a name element and a type element.
I admit that my DTD could be flawed, but what I'm very curious about is the name element. I have two name elements with different parent elements. Is that going to be a problem in my DTD?
Thanks!
- Bret
This is a totally newbie DTD question. Let's say that I have the following XML:
Code:
<?xml version="1.0" encoding="utf-16"?>
<root>
<person>
<name>John Doe</name>
<pets>
<pet>
<name>Fluffy</name>
<type>cat</type>
</pet>
<pet>
<name>Rover</name>
<type>dog</type>
</pet>
</pets>
</person>
</root>
Here is my first swing at the DTD:
Code:
<!ELEMENT root ( person ) >
<!ELEMENT person ( name, pets? ) >
<!ELEMENT name ( #PCDATA ) >
<!ELEMENT pets ( pet+ ) >
<!ELEMENT pet ( name, type ) >
<!ELEMENT name ( #PCDATA ) >
<!ELEMENT type ( #PCDATA ) >
In English: My root node must have only 1 person element. The person element must have a name element and may have a pets element. The pets element must have one or more pet elements. The pet element has a name element and a type element.
I admit that my DTD could be flawed, but what I'm very curious about is the name element. I have two name elements with different parent elements. Is that going to be a problem in my DTD?
Thanks!
- Bret