I have an error message on my XML Schema. To start, here is my XML file:
<?xml version="1.0" encoding="UTF-8"?>
<customer xmlns:xsi="http:www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation="customer.xsd">
<name>
<first>Bob</first>
<MI>H</MI>
<last>Jones</last>
</name>
<cnum>007389</cnum>
<mail_a>
<line1>12345 Mockingbird Lane</line1>
<city>Omaha</city>
<state>NE</state>
<zip>68123</zip>
<country>USA</country>
</mail_a>
<deliver_a>
<line1>12345 Mockingbird Lane</line1>
<city>Omaha</city>
<state>NE</state>
<zip>68123</zip>
<country>USA</country>
</deliver_a>
<member_date>1995-10-15</member_date>
<l_order_date>2003-08-02</l_order_date>
</customer>
And here is my schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer"/>
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="cnum"/>
<xs:element ref="mail_a"/>
<xs:element ref="deliver_a"/>
<xs:element ref="member_date"/>
<xs:element ref="l_order_date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="first" type="xs:string"/>
<xs:element name="MI" type="xs:string"/>
<xs:element name="last" type="xs:string"/>
<xs:element name="cnum" type="xs:integer"/>
<xs:element name="line1" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:integer"/>
<xs:element name="country" type="xs:string"/>
<xs:element name="member_date" type="xs:date"/>
<xs:element name="l_order_date" type="xs:date"/>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element ref="first"/>
<xs:element ref="MI"/>
<xs:element ref="last"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="mail_a">
<xs:complexType>
<xs:sequence>
<xs:element ref="line1"/>
<xs:element ref="city"/>
<xs:element ref="state"/>
<xs:element ref="zip"/>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="deliver_a">
<xs:complexType>
<xs:sequence>
<xs:element ref="line1"/>
<xs:element ref="city"/>
<xs:element ref="state"/>
<xs:element ref="zip"/>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The error that I'm getting is
The element type
xs:element
must be terminated by the matching end-tag</xs:element>
It appears that it doesn't like line 55 for some reason (element ref="line1"), which has a closing tag on it.
The XML file says that I'm missing the xs:schema end tag. Well, there it is... The editor that I'm using is oXygen.
Any thoughts? I've been fiddling around with it forever.
In addition to the premature closing of the customer
element declaration that @randominstanceOfLivingThing mentioned, you must change
xmlns:xsi="http:www.w3.org/2001/XMLSchema"
to
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
in your XML, then your XSD will be found and your XML will validate successfully.
Here are the entire, corrected XML and XSD files:
<?xml version="1.0" encoding="UTF-8"?>
<customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="try.xsd">
<name>
<first>Bob</first>
<MI>H</MI>
<last>Jones</last>
</name>
<cnum>007389</cnum>
<mail_a>
<line1>12345 Mockingbird Lane</line1>
<city>Omaha</city>
<state>NE</state>
<zip>68123</zip>
<country>USA</country>
</mail_a>
<deliver_a>
<line1>12345 Mockingbird Lane</line1>
<city>Omaha</city>
<state>NE</state>
<zip>68123</zip>
<country>USA</country>
</deliver_a>
<member_date>1995-10-15</member_date>
<l_order_date>2003-08-02</l_order_date>
</customer>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="cnum"/>
<xs:element ref="mail_a"/>
<xs:element ref="deliver_a"/>
<xs:element ref="member_date"/>
<xs:element ref="l_order_date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="first" type="xs:string"/>
<xs:element name="MI" type="xs:string"/>
<xs:element name="last" type="xs:string"/>
<xs:element name="cnum" type="xs:integer"/>
<xs:element name="line1" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:integer"/>
<xs:element name="country" type="xs:string"/>
<xs:element name="member_date" type="xs:date"/>
<xs:element name="l_order_date" type="xs:date"/>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element ref="first"/>
<xs:element ref="MI"/>
<xs:element ref="last"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="mail_a">
<xs:complexType>
<xs:sequence>
<xs:element ref="line1"/>
<xs:element ref="city"/>
<xs:element ref="state"/>
<xs:element ref="zip"/>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="deliver_a">
<xs:complexType>
<xs:sequence>
<xs:element ref="line1"/>
<xs:element ref="city"/>
<xs:element ref="state"/>
<xs:element ref="zip"/>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>