Question

When I attempt to validate a xml file via http://www.xmlvalidation.com/ I get 229 errors saying that all of the elements types must be declared. I'm not sure where I'm going wrong but here are my .xml and .xsd files...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="project3.xsl" ?>
<!-- Author: Michael Dahlke -->
<!-- Project: XML Project 3 -->
<!-- References: none -->
<!DOCTYPE ExchangeGroup [

    <!ENTITY me "Mexico">
    <!ENTITY ca "Canada">
    <!ENTITY us "United States">
    <!ENTITY br "Brazil">
    <!ENTITY jp "Japan">
    <!ENTITY it "Italy">

]> 

<ExchangeGroup xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
       xs:noNamespaceSchemaLocation="project3.xsd">
    <!-- *************************** Person 1 *************************** -->
    <Person type="S" id="E00001">   
        <Name>
            <FirstName>Michael</FirstName>
            <MiddleInitial>A</MiddleInitial>
            <LastName>Dahlke</LastName>
        </Name>

        <Address>
            <Street>12502 Seattle Slew Dr</Street>
            <Apartment>1822</Apartment>
            <City>Houston</City>
            <State>Texas</State>
            <PostalCode>77065</PostalCode>
            <Country>United States</Country>
        </Address>

        <Telephone>(920) 723-8749</Telephone>

        <EmailAddress>madahlke27@gmail.com</EmailAddress>

        <ApplicationDate>
            <Month>9</Month>
            <Day>08</Day>
            <Year>2013</Year>
        </ApplicationDate>

        <AvailableDate>
            <Month>9</Month>
            <Day>20</Day>
            <Year>2013</Year>
        </AvailableDate>

        <BirthCountry>United States</BirthCountry>

        <DateOfBirth>
            <Month>10</Month>
            <Day>24</Day>
            <Year>1988</Year>
        </DateOfBirth>

        <Age>24</Age>

        <Gender>M</Gender>

        <SchoolName>Madison College</SchoolName>

        <SchoolAddress>
            <Street>1701 Wright Street</Street>
            <Apartment></Apartment>
            <City>Madison</City>
            <State>Wisconsin</State>
            <PostalCode>53704</PostalCode>
            <Country>United States</Country>
        </SchoolAddress>

        <YearInSchool>Junior</YearInSchool>

        <MotherName>
            <FirstName>Tina</FirstName>
            <MiddleInitial>M</MiddleInitial>
            <LastName>Dahlke</LastName>
        </MotherName>

        <FatherName>
            <FirstName>Ron</FirstName>
            <MiddleInitial>P</MiddleInitial>
            <LastName>Dahlke</LastName>
        </FatherName>

        <EmergencyTelephone>(920) 723-8749</EmergencyTelephone>

        <FeePaid currency="dollar">$150</FeePaid>

        <Essay>
            <![CDATA[
            I want to participate in the exchange program to broaden my cultural understanding
            ]]>
        </Essay>

        <LanguagesSpoken>
            <Language fluency="4">English</Language>
            <Language fluency="2">Spanish</Language>
        </LanguagesSpoken>

        <CountryChoices>
            <Country preference="3">&br;</Country>
            <Country preference="1">&it;</Country>
            <Country preference="5">&ca;</Country>
            <Country preference="2">&jp;</Country>
            <Country preference="4">&me;</Country>
        </CountryChoices>
    </Person>

    <!-- *************************** Person 2 *************************** -->
    <Person type="S" id="E00002">   
        <Name>
            <FirstName>Jesse</FirstName>
            <MiddleInitial></MiddleInitial>
            <LastName> McCulloch</LastName>
        </Name>

        <Address>
            <Street>1256 El Dorado Trail</Street>
            <Apartment>101</Apartment>
            <City>Madison</City>
            <State>TX</State>
            <PostalCode>80956</PostalCode>
            <Country>United States</Country>
        </Address>

        <Telephone>(608) 777-6666</Telephone>

        <EmailAddress>jmc@hotmail.com</EmailAddress>

        <ApplicationDate>
            <Month>02</Month>
            <Day>01</Day>
            <Year>2011</Year>
        </ApplicationDate>

        <AvailableDate>
            <Month>02</Month>
            <Day>01</Day>
            <Year>2012</Year>
        </AvailableDate>

        <BirthCountry>United States</BirthCountry>

        <DateOfBirth>
            <Month>12</Month>
            <Day>25</Day>
            <Year>1975</Year>
        </DateOfBirth>

        <Age>36</Age>

        <Gender>M</Gender>

        <SchoolName>Bellview Alternative School</SchoolName>

        <SchoolAddress>
            <Street>555 Alternate Road</Street>
            <Apartment></Apartment>
            <City>Bellview</City>
            <State>TX</State>
            <PostalCode>80942</PostalCode>
            <Country>United States</Country>
        </SchoolAddress>

        <YearInSchool>Senior</YearInSchool>

        <MotherName>
            <FirstName>Barbara</FirstName>
            <MiddleInitial>M</MiddleInitial>
            <LastName>McCulloch</LastName>
        </MotherName>

        <FatherName>
            <FirstName>Jim</FirstName>
            <MiddleInitial>C</MiddleInitial>
            <LastName>McCulloch</LastName>
        </FatherName>

        <EmergencyTelephone>(608) 828-2222</EmergencyTelephone>

        <FeePaid currency="dollar">50</FeePaid>

        <Essay>
            <![CDATA[
            I want to participate in the exchange program to get away from my parents
            ]]>
        </Essay>

        <LanguagesSpoken>
            <Language fluency="4">English</Language>
            <Language fluency="3">Spanish</Language>
        </LanguagesSpoken>

        <CountryChoices>
            <Country preference="1">&br;</Country>
            <Country preference="2">&jp;</Country>
            <Country preference="3">&me;</Country>
            <Country preference="4">&ca;</Country>
            <Country preference="5">&it;</Country>
        </CountryChoices>
    </Person>

    <!-- *************************** Person 3 *************************** -->
    <Person type="S" id="E00003">   
        <Name>
            <FirstName>Naj</FirstName>
            <MiddleInitial>Ahmad</MiddleInitial>
            <LastName>Doemessenhier-Smith</LastName>
        </Name>

        <Address>
            <Street>456 House Lane</Street>
            <Apartment>1A</Apartment>
            <City>Isfahan</City>
            <Province>Dehshir</Province>
            <PostalCode>89632</PostalCode>
            <Country>Iran</Country>
        </Address>

        <Telephone>(608) 222-3333</Telephone>

        <EmailAddress>adoemess@gmail.com</EmailAddress>

        <ApplicationDate>
            <Month>01</Month>
            <Day>27</Day>
            <Year>2010</Year>
        </ApplicationDate>

        <AvailableDate>
            <Month>08</Month>
            <Day>27</Day>
            <Year>2011</Year>
        </AvailableDate>

        <BirthCountry>Iran</BirthCountry>

        <DateOfBirth>
            <Month>04</Month>
            <Day>06</Day>
            <Year>1995</Year>
        </DateOfBirth>

        <Age>16</Age>

        <Gender>M</Gender>

        <SchoolName>Super School</SchoolName>

        <SchoolAddress>
            <Street>456</Street>
            <Apartment></Apartment>
            <City>Super Street</City>
            <Province>Isfahan</Province>
            <PostalCode>89632</PostalCode>
            <Country>Iran</Country>
        </SchoolAddress>

        <YearInSchool>Junior</YearInSchool>

        <MotherName>
            <FirstName>Maja</FirstName>
            <MiddleInitial>Q</MiddleInitial>
            <LastName>Mastana</LastName>
        </MotherName>

        <FatherName>
            <FirstName>Najim</FirstName>
            <MiddleInitial></MiddleInitial>
            <LastName>Doemessenhier</LastName>
        </FatherName>

        <EmergencyTelephone>(608) 333-2222</EmergencyTelephone>

        <FeePaid currency="irr">50</FeePaid>

        <Essay>
            <![CDATA[
            I wish to participate in the exchange program becuase other countries have better Anime choices.
            ]]>
        </Essay>

        <LanguagesSpoken>
            <Language fluency="4">Farsi</Language>
            <Language fluency="2">English</Language>
        </LanguagesSpoken>

        <CountryChoices>
            <Country preference="1">&br;</Country>
            <Country preference="2">&jp;</Country>
            <Country preference="3">&me;</Country>
            <Country preference="4">&ca;</Country>
            <Country preference="5">&it;</Country>
        </CountryChoices>
    </Person>

    <!-- *************************** Person 4 *************************** -->
    <Person type="T" id="E00004">   
        <Name>
            <FirstName>Virginia</FirstName>
            <MiddleInitial></MiddleInitial>
            <LastName>Calabrese</LastName>
        </Name>

        <Address>
            <Street>101 Iota Court</Street>
            <Apartment></Apartment>
            <City>Vatican City</City>
            <Province>Vatican</Province>
            <PostalCode>78546</PostalCode>
            <Country>Italy</Country>
        </Address>

        <Telephone>(608) 123-7896</Telephone>

        <EmailAddress>vcalabrese@gmail.com</EmailAddress>

        <ApplicationDate>
            <Month>11</Month>
            <Day>14</Day>
            <Year>2010</Year>
        </ApplicationDate>

        <AvailableDate>
            <Month>08</Month>
            <Day>01</Day>
            <Year>2012</Year>
        </AvailableDate>

        <BirthCountry>Italy</BirthCountry>

        <!-- Exempt for teachers
        <DateOfBirth>
            <Month></Month>
            <Day></Day>
            <Year></Year>
        </DateOfBirth>

        <Age></Age>
        END Exempt for teachers -->

        <Gender>F</Gender>

        <SchoolName>Bella Instructoria</SchoolName>

        <SchoolAddress>
            <Street>7854 Scuola Di Via</Street>
            <Apartment></Apartment>
            <City>Vatican City</City>
            <State>Vatican</State>
            <PostalCode>89632</PostalCode>
            <Country>Italy</Country>
        </SchoolAddress>

        <YearInSchool></YearInSchool>

        <MotherName>
            <FirstName></FirstName>
            <MiddleInitial></MiddleInitial>
            <LastName></LastName>
        </MotherName>

        <FatherName>
            <FirstName></FirstName>
            <MiddleInitial></MiddleInitial>
            <LastName></LastName>
        </FatherName>

        <EmergencyTelephone>(608) 458-9852</EmergencyTelephone>

        <FeePaid currency="euro">50</FeePaid>

        <Essay>
            <![CDATA[
            I wish to participate in the exchange program to help students in other countries learn Italian.
            ]]>
        </Essay>

        <LanguagesSpoken>
            <Language fluency="4">Italian</Language>
            <Language fluency="3">English</Language>
        </LanguagesSpoken>

        <CountryChoices>
            <Country preference="1">&br;</Country>
            <Country preference="2">&jp;</Country>
            <Country preference="3">&me;</Country>
            <Country preference="4">&ca;</Country>
            <Country preference="5">&us;</Country>
        </CountryChoices>
    </Person>

</ExchangeGroup>

AND .xsd ....

<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="ExchangeGroup">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Person" minOccurs="4" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="Person">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Name" />
            <xs:element ref="Address" />
            <xs:element ref="Telephone" />
            <xs:element ref="EmailAddress" minOccurs="1" maxOccurs="unbounded" />
            <xs:element ref="ApplicationDate" />
            <xs:element ref="AvailableDate" />
            <xs:element ref="BirthCountry" />
            <xs:element ref="DateOfBirth" minOccurs="0" />
            <xs:element ref="Age" minOccurs="0" />
            <xs:element ref="Gender" />
            <xs:element ref="SchoolName" />
            <xs:element ref="SchoolAddress" />
            <xs:element ref="YearInSchool" />
            <xs:element ref="MotherName" />
            <xs:element ref="FatherName" />
            <xs:element ref="EmergencyTelephone" />
            <xs:element ref="FeePaid" />
            <xs:element ref="Essay" />
            <xs:element ref="LanguagesSpoken" />
            <xs:element ref="CountryChoices" />
        </xs:sequence>

        <xs:attribute ref="type" />
        <xs:attribute ref="id" />

    </xs:complexType>
</xs:element>

<xs:element name="Name">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="FirstName" />
            <xs:element ref="MiddleInitial" minOccurs="0" maxOccurs="1" />
            <xs:element ref="LastName" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="Address">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Street" />
            <xs:element ref="Apartment" />
            <xs:element name="City" />
            <xs:element ref="State" minOccurs="0" />
            <xs:element ref="Province" minOccurs="0" />
            <xs:element ref="PostalCode" />
            <xs:element ref="Country" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="Telephone" type="telephone" />

<xs:element name="EmailAddress" />

<xs:element name="ApplicationDate">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Month" />
            <xs:element ref="Day" />
            <xs:element ref="Year" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="AvailableDate">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Month" />
            <xs:element ref="Day" />
            <xs:element ref="Year" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="BirthCountry" />

<xs:element name="DateOfBirth">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Month" />
            <xs:element ref="Day" />
            <xs:element ref="Year" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="Age">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
            <xs:pattern value="[0-9]*" />
            <xs:minInclusive value="13" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name="Gender">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="M|F" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name="SchoolName" />

<xs:element name="SchoolAddress">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Street" />
            <xs:element ref="Apartment" />
            <xs:element name="City" />
            <xs:element ref="State" minOccurs="0" />
            <xs:element ref="Province" minOccurs="0" />
            <xs:element ref="PostalCode" />
            <xs:element ref="Country" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="YearInSchool" />

<xs:element name="MotherName">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="FirstName" />
            <xs:element ref="MiddleInitial" minOccurs="0" maxOccurs="1" />
            <xs:element ref="LastName" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="FatherName">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="FirstName" />
            <xs:element ref="MiddleInitial" minOccurs="0" maxOccurs="1" />
            <xs:element ref="LastName" />
        </xs:sequence>  
    </xs:complexType>
</xs:element>

<xs:element name="EmergencyTelephone" type="telephone" />   

<xs:element name="FeePaid" >
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="currency" type="currencyType" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:element>   

<xs:element name="Essay">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name="LanguagesSpoken">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Language" minOccurs="1" maxOccurs="5" >
                <xs:complexType>
                    <xs:simpleContent>
                        <xs:extension base="xs:string">
                            <xs:attribute ref="fluency" use="required" />
                        </xs:extension>
                    </xs:simpleContent>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="CountryChoices">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Country" minOccurs="5" maxOccurs="5" >
                <xs:complexType>
                    <xs:simpleContent>
                        <xs:extension base="xs:string">
                            <xs:attribute ref="preference" use="required" />
                        </xs:extension>
                    </xs:simpleContent>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

</xs:element>

<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
<xs:element name="MiddleInitial" type="xs:string" />
<xs:element name="Day" type="dayType"  />
<xs:element name="Month" type="monthType" />
<xs:element name="Year" type="yearType" />
<xs:element name="price" type="xs:decimal" />


<xs:element name='Apartment'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z0-9]*" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name='State'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z]*" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name='Province'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z]*" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name='Country'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z, ]+" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:element name='PostalCode'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{5,9}" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<xs:simpleType name="telephone">
    <xs:restriction base="xs:string">
        <xs:pattern value="\([0-9]{3}\) [0-9]{3}[-][0-9]{4}" />
    </xs:restriction>
</xs:simpleType>

<xs:attribute name='type'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[S|T]?" />
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>

<xs:attribute name='fluency'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="1|2|3|4|5" />
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>

<xs:attribute name='preference'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="1|2|3|4|5" />
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>

<xs:attribute name='id'>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="E[0-9]{5}" />
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>

<xs:simpleType name="currencyType">
    <xs:restriction base="xs:string">
        <xs:pattern value="dollar|irr|euro|peso|yen" />
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="dayType">
    <xs:restriction base="xs:string">
        <xs:pattern value="0?[1-9]|[12][0-9]|3[01]?" />
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="monthType">
    <xs:restriction base="xs:string">
        <xs:pattern value="0?[1-9]|1[0-2]?" />
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="yearType">
    <xs:restriction base="xs:integer">
        <xs:minInclusive value="1900" />
        <xs:maxInclusive value="3013" />
    </xs:restriction>
</xs:simpleType>

</xs:schema>
Was it helpful?

Solution

It validates fine with xerces.

I'd guess it's that particular online validator. I've had trouble with it before, for more complex/unusual schemas. For example, if you look at the last error, it had trouble with the [-] in your regex (which it should accept). BTW: it was because of such problems with this particular online validator, and all the other ones I tried (and even with installing xmllint) that I started using xerces. No problems so far.

On a hunch, I removed the entity definitions from your xml (and all the uses!), and that online validator then accepted it.

Answer: It's not you. http://www.xmlvalidation.com/ seems to be going wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top