Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTD question - deling with child elements will the names?

Status
Not open for further replies.

clone45

Programmer
Mar 28, 2006
22
0
0
US
Hello!

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
 
Oh shoot, I really mangled the subject. Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top