0

XMLドキュメントからのこのDTDが検証されない理由がわかりません。それが私に与えているエラーは、最後の行に「ドキュメント要素がありません」です。このコードの2行を除くすべてを削除でき、それでもエラーが発生するため、これはばかげています。私はXMLの初心者なので、もう少し経験のある人が私を探してくれるかもしれません。

<?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)> 
]>
4

1 に答える 1

1

W3C XML / HTML Markup Validationサービスは、DTD自体ではなく、ドキュメントを検証するだけです。次のように、有効なドキュメントをDTDに追加して、DTDとドキュメントの両方をチェックします。

<?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>
于 2013-01-27T19:51:04.780 に答える