Xsd v2 and anonymous includes

I've got an XML schema where I include a set of anonymous types. When running XSD to generate a class it doesn't seem to handle it very well. It ignores all of the types declared in the XML schema file. Meanwhile tools like XmlSpy and Stylus Studio seem to validate the documents without a problem.

Schema validation warning: Type 'http://schemas.mydomain.com/Storefront/AddressBook:RestrictedLengthString' is not declared, or is not a simple type. L
ine 32, position 6.

The source schema looks like this:

<xs:schema id="AddressBook"
attributeFormDefault="unqualified"
elementFormDefault="unqualified"
targetNamespace="http://schemas.mydomain.com/Storefront/AddressBook"
version="3.0"
xmlns="http://schemas.mydomain.com/Storefront/AddressBook"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:include schemaLocation="..\Address.xsd" />
<xs:include schemaLocation="..\CommonTypes.xsd" />

<xs:element name="AddressBook">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="Address">
<xs:attribute name="DateCreated" type="xs:dateTime" />
<xs:attribute name="DateLastModified" type="xs:dateTime" />
<xs:attribute name="DeliveryMethodId" type="Guid" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

While the common types one looks like this:

< xml version="1.0" encoding="utf-16" >
<xs:schema id="CommonTypes"
attributeFormDefault="unqualified"
elementFormDefault="unqualified"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="Guid">
<xs:restriction base="xs:string">
<xs:pattern value="\{{0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}{0,1}" />
</xs:restriction>
</xs:simpleType>
</xs:schema>

Thoughts

Thanks,
Colin





Answer this question

Xsd v2 and anonymous includes

  • jackline

    Hi Colin,

    Can you include address.xsd as well It looks like the error might be related to that file.

    Stan



  • Xsd v2 and anonymous includes