Reputation: 81
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Person">
<xs:complexType>
<xs:all>
<xs:element name="address" type="Address"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="line1" type="xs:string"/>
<xs:element name="line2" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="postcode" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
In this XSD definition I am unable to understand this error: Type 'Address' is not defined as root item within this schema or any included or imported schemas.
I suppose the type declaration is provided in the same schema. But what is wrong with this declaration?
Upvotes: 0
Views: 234
Reputation: 12154
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Person">
<xs:complexType>
<xs:all>
<xs:element name="address" type="Address"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="line1" type="xs:string"/>
<xs:element name="line2" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="postcode" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Upvotes: 2
Reputation: 163282
You have a local element declaration
<xs:element name="address" type="Address"/>
but there is no complexType definition with name="Address".
I suspect that the element declaration
<xs:element name="Address">
<xs:complexType>
...
should probably be
<xs:complexType name="Address">
...
Upvotes: 1