我无法弄清楚这一点。我正在使用http://www.xmlvalidation.com/在以下文档中验证我的内部DTD。我不断得到上述错误,因为我的生活无法理解......任何帮助都会非常感激!
XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE exchanges[
<!ELEMENT exchanges (exchange*)>
<!ATTLIST exchange exchangeType (S|T) #REQUIRED>
<!ATTLIST exchange id ID #REQUIRED>
<!ELEMENT exchange (name, address, telephone, emailAddress, applicationDate, availableDate, birthCountry, dateOfBirth?, age?, gender, schoolAddress, yearInSchool?, motherName?, fatherName?, emergencyTelephone, feePaid, essay, spokenLanguages, countryChoices)>
<!ELEMENT name (lastName, firstName, middleInitial?)>
<!ELEMENT lastName (#PCDATA)>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT middleInitial (#PCDATA)>
<!ELEMENT address (street, apartment?, city, (state|province), (zipCode|postalCode), country)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT apartment (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT province (#PCDATA)>
<!ELEMENT zipCode (#PCDATA)>
<!ELEMENT postalCode (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT telephone (#PCDATA)>
<!ELEMENT emailAddress (#PCDATA)>
<!ELEMENT applicationDate (month, day, year)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT availableDate (month, day, year)>
<!ELEMENT birthCountry (#PCDATA)>
<!ELEMENT dateOfBirth (month, day, year)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT gender (#PCDATA)>
<!ELEMENT schoolName (#PCDATA)>
<!ELEMENT schoolAddress (street, apartment?, city, (state|province), (zipCode|postalCode), country)>
<!ELEMENT yearInSchool (#PCDATA)>
<!ELEMENT motherName (lastName, firstName, middleInitial?)>
<!ELEMENT fatherName (lastName, firstName, middleInitial?)>
<!ELEMENT emergencyTelephone (#PCDATA)>
<!ELEMENT feePaid (#PCDATA)>
<!ATTLIST feePaid currency CDATA #REQUIRED>
<!ELEMENT essay (#PCDATA)>
<!ELEMENT spokenLanguages (language, language, language*)>
<!ATTLIST language fluency (1|2|3|4) #REQUIRED>
<!ELEMENT language (#PCDATA)>
<!ENTITY eng "English">
<!ENTITY spa "Spanish">
<!ENTITY jap "Japanese">
<!ENTITY fre "French">
<!ELEMENT countryChoices (countryChoice, countryChoice, countryChoice, countryChoice, countryChoice)>
<!ATTLIST countryChoice rank (1|2|3|4|5) #REQUIRED>
<!ELEMENT countryChoice (#PCDATA)>
<!ENTITY me "Mexico">
<!ENTITY ca "Canada">
<!ENTITY us "United States">
<!ENTITY br "Brazil">
<!ENTITY jp "Japan">
<!ENTITY it "Italy">
]>
<exchanges>
<exchange id="I00001" exchangeType="S">
<name>
<lastName>StudentLastName</lastName>
<firstName>StudentFirstName</firstName>
<middleInitial>I</middleInitial>
</name>
<address>
<street>1701 Wright Street</street>
<apartment></apartment>
<city>Madison</city>
<state>WI</state>
<zipCode>53704</zipCode>
<country>United States</country>
</address>
<telephone>(608) 555-1234</telephone>
<emailAddress>studentemail@madisoncollege.edu</emailAddress>
<applicationDate>
<month>3</month>
<day>23</day>
<year>2015</year>
</applicationDate>
<availableDate>
<month>3</month>
<day>25</day>
<year>2015</year>
</availableDate>
<birthCountry>United States</birthCountry>
<dateOfBirth>
<month>1</month>
<day>22</day>
<year>1997</year>
</dateOfBirth>
<age>18</age>
<gender>male</gender>
<schoolName>Madison Area High School</schoolName>
<schoolAddress>
<street>123 School Street</street>
<city>Madison</city>
<state>WI</state>
<zipCode>53717</zipCode>
<country>USA</country>
</schoolAddress>
<yearInSchool>Senior</yearInSchool>
<motherName>
<lastName>StudentParent</lastName>
<firstName>Mom</firstName>
<middleInitial>H</middleInitial>
</motherName>
<fatherName>
<lastName>StudentParent</lastName>
<firstName>Dad</firstName>
<middleInitial>K</middleInitial>
</fatherName>
<emergencyTelephone>(608) 123-4567</emergencyTelephone>
<feePaid currency="USD">500.00</feePaid>
<essay>
<![CDATA[
Sample of exchange essay for me to apply. Why do I want to go?
]]>
</essay>
<spokenLanguages>
<language fluency="3">German</language>
<language fluency="3">English</language>
<language fluency="1">Spanish</language>
</spokenLanguages>
<countryChoices>
<countryChoice rank="1">Germany</countryChoice>
<countryChoice rank="3">Brazil</countryChoice>
<countryChoice rank="5">Mexico</countryChoice>
<countryChoice rank="2">France</countryChoice>
<countryChoice rank="4">England</countryChoice>
</countryChoices>
</exchange>
<exchange id="I00002" exchangeType="S">
<name>
<lastName>Smith-William</lastName>
<firstName>Julian</firstName>
<middleInitial>J</middleInitial>
</name>
<address>
<street>123 Some Street</street>
<apartment></apartment>
<city>Portland</city>
<state>OR</state>
<zipCode>12345</zipCode>
<country>United States</country>
</address>
<telephone>(123) 123-4567</telephone>
<emailAddress>smith-william@madisoncollege.edu</emailAddress>
<applicationDate>
<month>1</month>
<day>14</day>
<year>2015</year>
</applicationDate>
<availableDate>
<month>2</month>
<day>13</day>
<year>2015</year>
</availableDate>
<birthCountry>United States</birthCountry>
<dateOfBirth>
<month>4</month>
<day>5</day>
<year>1998</year>
</dateOfBirth>
<age>16</age>
<gender>male</gender>
<schoolName>Westview High School</schoolName>
<schoolAddress>
<street>44566 Westview Road</street>
<city>Portland</city>
<state>Oregon</state>
<zipCode>12345</zipCode>
<country>United States</country>
</schoolAddress>
<yearInSchool>Junior</yearInSchool>
<motherName>
<lastName>Smith</lastName>
<firstName>Peggy</firstName>
<middleInitial>H</middleInitial>
</motherName>
<fatherName>
<lastName>Williams</lastName>
<firstName>Ralph</firstName>
<middleInitial>Y</middleInitial>
</fatherName>
<emergencyTelephone>(608) 555-4456</emergencyTelephone>
<feePaid currency="USD">50.00</feePaid>
<essay>
<![CDATA[
I have worked all my life and would like to travel. In order for me to be considered to
be a foreign exchange student, I would need a scholarship.
]]>
</essay>
<spokenLanguages>
<language fluency="2">Greek</language>
<language fluency="4">English</language>
</spokenLanguages>
<countryChoices>
<countryChoice rank="2">Finland</countryChoice>
<countryChoice rank="5">Norway</countryChoice>
<countryChoice rank="1">Brazil</countryChoice>
<countryChoice rank="3">Japan</countryChoice>
<countryChoice rank="4">Egypt</countryChoice>
</countryChoices>
</exchange>
<exchange id="I00003" exchangeType="S">
<name>
<lastName>Morimoto</lastName>
<firstName>Vivian</firstName>
<middleInitial></middleInitial>
</name>
<address>
<street>112 Japan Street</street>
<city>Bunkyo-ku</city>
<province>Tokyo</province>
<postalCode>100-6805</postalCode>
<country>Japan</country>
</address>
<telephone>(111) 222-3333</telephone>
<emailAddress>vmorimoto@madisoncollege.edu</emailAddress>
<applicationDate>
<month>1</month>
<day>6</day>
<year>2015</year>
</applicationDate>
<availableDate>
<month>2</month>
<day>13</day>
<year>2015</year>
</availableDate>
<birthCountry>Japan</birthCountry>
<dateOfBirth>
<month>9</month>
<day>3</day>
<year>1997</year>
</dateOfBirth>
<age>17</age>
<gender>female</gender>
<schoolName>Tokyo's Finest High School</schoolName>
<schoolAddress>
<street>1223 High School Street</street>
<city>Bunkyo-ku</city>
<province>Tokyo</province>
<postalCode>100-6805</postalCode>
<country>Japan</country>
</schoolAddress>
<yearInSchool>Junior</yearInSchool>
<motherName>
<lastName>Morimoto</lastName>
<firstName>Tina</firstName>
<middleInitial>K</middleInitial>
</motherName>
<fatherName>
<lastName>Morimoto</lastName>
<firstName>Katsumoto</firstName>
<middleInitial>Q</middleInitial>
</fatherName>
<emergencyTelephone>(608) 555-2222</emergencyTelephone>
<feePaid currency="JPY">1000.00</feePaid>
<essay>
<![CDATA[
This would be a great opportunity for me to get out and see the world. I truly enjoy
living in Japan, but I would also love to travel around the world and this opportunity
would give me a chance to do so. France would be a dream trip, but going to the United
States would also be quite wonderful. Those are my top two choices, but in the end--any
opportunity to go to any country would be an absolute thrill!!
]]>
</essay>
<spokenLanguages>
<language fluency="3">Engish</language>
<language fluency="4">Japanese</language>
<language fluency="2">French</language>
</spokenLanguages>
<countryChoices>
<countryChoice rank="2">United States</countryChoice>
<countryChoice rank="4">Germany</countryChoice>
<countryChoice rank="3">Canada</countryChoice>
<countryChoice rank="5">Italy</countryChoice>
<countryChoice rank="1">France</countryChoice>
</countryChoices>
</exchange>
<exchange id="I000004" exchangeType="T">
<name>
<lastName>Walden</lastName>
<firstName>Mary-Jo</firstName>
<middleInitial>U</middleInitial>
</name>
<address>
<street>333 North Shore Blvd</street>
<apartment>310</apartment>
<city>Miami</city>
<state>FL</state>
<zipCode>32408</zipCode>
<country>United States</country>
</address>
<telephone>(555) 222-4456</telephone>
<emailAddress>teacher@madisoncollege.edu</emailAddress>
<applicationDate>
<month>5</month>
<day>22</day>
<year>2014</year>
</applicationDate>
<availableDate>
<month>6</month>
<day>1</day>
<year>2015</year>
</availableDate>
<birthCountry>Canada</birthCountry>
<gender>female</gender>
<schoolName>Simple High School</schoolName>
<schoolAddress>
<street>1223 Some Nice Street</street>
<city>Miami</city>
<state>FL</state>
<zipCode>32417</zipCode>
<country>United States</country>
</schoolAddress>
<emergencyTelephone>(333) 435-3423</emergencyTelephone>
<feePaid currency="USD">200.00</feePaid>
<essay>
<![CDATA[
I am coming to bring my knowledge and experience to others, but more so to learn
from others and become a better person.
]]>
</essay>
<spokenLanguages>
<language fluency="2">German</language>
<language fluency="4">English</language>
<language fluency="3">Japanese</language>
</spokenLanguages>
<countryChoices>
<countryChoice rank="4">Germany</countryChoice>
<countryChoice rank="1">Japan</countryChoice>
<countryChoice rank="3">Brazil</countryChoice>
<countryChoice rank="5">Germany</countryChoice>
<countryChoice rank="2">France</countryChoice>
</countryChoices>
</exchange>
</exchanges>
再次感谢任何可以提供帮助的人!
答案 0 :(得分:2)
您有schoolName
作为每个exchange
的子元素,但未在您的DTD中定义:
<!ELEMENT exchange (name, address, telephone, emailAddress, applicationDate,
availableDate, birthCountry, dateOfBirth?, age?, gender, schoolAddress, yearInSchool?,
motherName?, fatherName?, emergencyTelephone, feePaid, essay,
spokenLanguages, countryChoices)>