Document Type Definition - DTD / XML

Soldato
Joined
27 Jun 2006
Posts
6,331
Hey folks,

Trying to get my head around this, although anything I've stumbled upon online is a tad too complex for my actual needs.

I just wish to know if something like this is a valid DTD, using the example of Wayne Rooney, who is a player within the FA Premiership.

Code:
<!ELEMENT List (Item)+>
<!ELEMENT Item (#PCDATA)>

<fapremiershipplayers>
    <player>
         <name>Wayne Rooney</name>
         <nationality>English</nationality>
         <age>22</age>
         <size>Fat</size>
         <position>Striker</position>
    </player>
</fapremiershipplayers>

The plan of such a dtd would be that many players would fit in between the 'FA Premiership Players' brackets, but I'm unsure if this is valid practice or if I should uniquely identify each player instead.

Thanks for any help. :)
 
Back again. This time it's a file containing reasons for choosing 3 types of dog.

Code:
<?xml version="1.0" ?>
<!DOCTYPE recommendeddogs [
<!ELEMENT recommendeddogs (#PCDATA)>
<!ELEMENT dog (group*,breed*,size*,grooming*,exercise*,locality*,lifespan*,reason*)>
<!ELEMENT group (#PCDATA)>
<!ELEMENT breed (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT grooming (#PCDATA)>
<!ELEMENT exercise (#PCDATA)> 
<!ELEMENT locality (#PCDATA)>
<!ELEMENT lifespan (#PCDATA)>
<!ELEMENT reason (#PCDATA)>
]>


<recommendeddogs>
        <dog>
        <group>Terrier</group>
        <breed>Jack Russell</breed>
        <size>10" Tall</size>
        <grooming>Moderate</grooming>
        <exercise>Weekly</exercise>
        <locality>Belfast</locality>
        <lifespan>7 years</lifespan>
        <reason>Jack Russells dont require much maintenance as they are a small dog. They are very loyal, fun and they enjoy exercise and walking.</reason>
        </dog>
                    <dog>
                    <group>Working</group>
                    <breed>Border Collie</breed>
                    <size>26" Tall</size>
                    <grooming>Moderate</grooming>
                    <exercise>Daily</exercise>
                    <locality>Lurgan</locality>
                    <lifespan>8 years</lifespan>
                    <reason>Border collies are very energetic dogs. They enjoy a lot of daily exercise and are affectionate. They are very well disciplined and therefore are house-trained relatively easier than other dogs.</reason>
                   </dog>
                                          <dog>
                                          <group>Hound</group>
                                          <breed>Dachshund</breed>
                                          <size>11" Tall</size>
                                          <grooming>Moderate</grooming>
                                          <exercise>Bi-Weekly</exercise>
                                          <locality>Carrickfergus</locality>
                                          <lifespan>5 years</lifespan>
                                          <reason>Dachshunds are very low maintenance when it comes to exercise as excessive amounts can cause them health problems. Their diet is carefully monitored also but they are very affectionate, loyal and fun dogs.</reason>
                                          </dog>
</recommendeddogs>

Could someone please tell me where I am going wrong with that?

The error report is:

Code:
Errors:

line 26, scratch.xml:
    error (1152): element violates enclosing tag's content model: dog 
line 36, scratch.xml:
    error (1152): element violates enclosing tag's content model: dog 
line 46, scratch.xml:
    error (1152): element violates enclosing tag's content model: dog 

Warnings:

line 13, scratch.xml:
    warning (690): end of DTD; unused element(s) detected: exercise, grooming, group, breed, reason, size, locality, dog, lifespan

I think the depression is kicking in.
 
Back
Top Bottom