juan rangel
juan rangel

Reputation: 11

DTD DOCTYPE declaration close before intended

Hello fisrt time posting. i was doing a dtd to validate an xml and idk why when my code is readed the doctype declaration is closed with the ">" of the fisrt element of the dtd instead of at the end where the "]>" is placed. i have spend a few hours with this but no one of my friends knows xml.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE torneo [

<!ELEMENT torneo (edicion, anteriorGanador, participante+)>
<!ATTLIST torneo 
edicion CDATA #REQUIRED
anteriorGanador CDATA #REQUIRED>
<!ELEMENT participante (idP, pareja, nombre, edad, cabezaDeSerie?)>
<!ATTLIST participante 
idP ID #REQUIRED
pareja IDREF #REQUIRED>
<!ELEMENT nombre (#PCDATA)>
<!ELEMENT edad (#PCDATA)>
<!ELEMENT cabezaDeSerie (EMPTY)>
]>

Upvotes: 1

Views: 56

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

You seem to want edicion and anteriorGanador to be attributes of torneo, and idP and pareja to be attributes of participante. To get this to work, just remove the specification of those attributes as sub-elements.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE torneo [

<!ELEMENT torneo (participante+)>
<!ATTLIST torneo 
    edicion CDATA #REQUIRED
    anteriorGanador CDATA #REQUIRED>
<!ELEMENT participante (nombre, edad, cabezaDeSerie?)>
<!ATTLIST participante 
    idP ID #REQUIRED
    pareja IDREF #REQUIRED>
<!ELEMENT nombre (#PCDATA)>
<!ELEMENT edad (#PCDATA)>
<!ELEMENT cabezaDeSerie (EMPTY)>
]>
<torneo edicion="a" anteriorGanador="zzz">
    <participante idP="xxx" pareja="xxx">
        <nombre>asdf</nombre>
        <edad>33</edad>
    </participante>
</torneo>

Upvotes: 1

Related Questions