In the schema below, the line <xs:element type="cmn:AddressType" name="ResidentialAddress" minOccurs="1" maxOccurs="1" />
gives an error Type 'http://company.com/Common:AddressType' is not declared
.
Does anyone know why? It shows in the Visual Studio 2008 editor, and also if I try validate an XML file with XDocument
.
Schema Student.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Student"
xmlns:cmn="http://company.com/Common"
targetNamespace="http://company.com/Student"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:import id="cmn" schemaLocation="Address.xsd"
namespace="http://company.com/Common" />
<xs:element name="Student" nillable="false">
<xs:complexType>
<xs:sequence minOccurs="1">
<xs:element name="Id" type="xs:integer" nillable="false" minOccurs="1" maxOccurs="1" />
<xs:element type="cmn:AddressType" name="ResidentialAddress" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Schema Address.xsd:
<xs:schema
targetNamespace="http://company.com/Common"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="AddressType">
<xs:complexType>
<xs:sequence>
<xs:element name="Line1" minOccurs="1" maxOccurs="1" />
<xs:element name="Line2" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>