Reputation: 1489
I don't understand why this DTD from an XML document will not validate. The error it's giving me is "no document element" on the last line. Which is stupid because I can delete all but two lines of this code and it still gives me the error. I'm fairly beginner at XML so maybe someone with a little more experience take a look for me?
<?xml version = "1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE events [
<!ELEMENT events (event)+>
<!ELEMENT event (itenerary, description, icon?, leader+, coordinator+, maxpart, registeredpart, carpool?, difficulty, cost?, destination)>
<!ELEMENT itenerary (startdate, enddate, departuretime, location)>
<!ELEMENT contact (name,phone+)>
<!ELEMENT name (firstname, lastname)>
<!ELEMENT startdate (year, month, day)>
<!ELEMENT enddate (year, month, day)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ELEMENT departuretime (hours,minutes)>
<!ELEMENT hours (#PCDATA)>
<!ELEMENT minutes (#PCDATA)>
<!ELEMENT location (street,city)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT icon (#PCDATA)>
<!ELEMENT leader (contact+)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT phone (landline?, cell?)>
<!ELEMENT coordinator (contact)>
<!ELEMENT landline (#PCDATA)>
<!ELEMENT cell (#PCDATA)>
<!ELEMENT maxpart (#PCDATA)>
<!ELEMENT registeredpart (#PCDATA)>
<!ELEMENT carpool (#PCDATA)>
<!ELEMENT difficulty (#PCDATA)>
<!ELEMENT cost (#PCDATA)>
<!ELEMENT destination (location)>
]>
Upvotes: 0
Views: 6439
Reputation: 288060
The W3C XML/HTML Markup Validation service just validates documents, and not DTDs themselves. Append a valid document to your DTD to check both DTD and document, like this:
<?xml version = "1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE events [
<!ELEMENT events (event)+>
<!ELEMENT event (itenerary, description, icon?, leader+, coordinator+, maxpart, registeredpart, carpool?, difficulty, cost?, destination)>
<!ELEMENT itenerary (startdate, enddate, departuretime, location)>
<!ELEMENT contact (name,phone+)>
<!ELEMENT name (firstname, lastname)>
<!ELEMENT startdate (year, month, day)>
<!ELEMENT enddate (year, month, day)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ELEMENT departuretime (hours,minutes)>
<!ELEMENT hours (#PCDATA)>
<!ELEMENT minutes (#PCDATA)>
<!ELEMENT location (street,city)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT icon (#PCDATA)>
<!ELEMENT leader (contact+)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT phone (landline?, cell?)>
<!ELEMENT coordinator (contact)>
<!ELEMENT landline (#PCDATA)>
<!ELEMENT cell (#PCDATA)>
<!ELEMENT maxpart (#PCDATA)>
<!ELEMENT registeredpart (#PCDATA)>
<!ELEMENT carpool (#PCDATA)>
<!ELEMENT difficulty (#PCDATA)>
<!ELEMENT cost (#PCDATA)>
<!ELEMENT destination (location)>
]>
<events>
<event>
<itenerary><!-- Did you mean itinerary ? -->
<startdate><year>2013</year><month>1</month><day>1</day></startdate>
<enddate><year>2013</year><month>1</month><day>2</day></enddate>
<departuretime><hours>12</hours><minutes>01</minutes></departuretime>
<location>
<street>Kölner Straße</street>
<city>Düsseldorf</city>
</location>
</itenerary>
<description>A short trip</description>
<leader>
<contact><name><firstname>John</firstname><lastname>Smith</lastname></name><phone/></contact>
</leader>
<coordinator>
<contact><name><firstname>Jane</firstname><lastname>Smith</lastname></name><phone/></contact>
</coordinator>
<maxpart>??</maxpart>
<registeredpart>???</registeredpart>
<difficulty>easy</difficulty>
<destination>
<location>
<street>Aachener Straße</street>
<city>Düsseldorf</city>
</location>
</destination>
</event>
</events>
Upvotes: 1