I have problem with file includes in XML schemas. The scenario is as follows. The validation of file MyFile.xsd succeeds against MXSML4.0 and Microsoft .Net. However, it fails on XML Spy!
MyFile.xsd INCLUDES the following definition
CommonSimpleTypes INCLUDES the following name space definition:
ContactTypes INCLUDES the follow definition
However, when validating in the text view in XML Spy, I get validation error The file is not valid: Schema error- undefined value for 'type' encounteredagainst the line
in ContactTypes. However, validating ContactTypes alone works fine.
If I open MyFile.xsd in the Schema Design view and select validate, I get error The file is not valid:No Type with Name "TelephoneNumberType" has been defined in this or included/imported schemas in the ContactTypes Schema!
I think it MIGHT have something to do with the import/include for CommonSimpleTypes. However, if I take out the include for CommonSimpleTypes in MyFile.xsd, I get error when trying to use "RestrictedSimpleType".
What is wrong?
MyFile.xsd INCLUDES the following definition
Code:
<xsd:schema targetNamespace="[URL unfurl="true"]http://www.mycompany.org/form"[/URL] xmlns:APD="[URL unfurl="true"]http://www.parentcompany.com/people/AddressAndPersonalDetails"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] xmlns="[URL unfurl="true"]www.mycompany.org/form"[/URL] elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4" id="F01">
<xsd:include schemaLocation="people/CommonSimpleTypes-v1.xsd"/>
<xsd:import namespace="[URL unfurl="true"]http://www.parentcompany.com/people/AddressAndPersonalDetails"[/URL] schemaLocation="govtalk/ContactTypes-v1.xsd"/>
<!-- RestrictedStringType is defined in CommonSimpleTypes-->
<xsd:simpleType name="F01Name">
<xsd:restriction base="RestrictedStringType">
<xsd:minLength value="1"/>
<xsd:maxLength value="70"/>
</xsd:restriction>
</xsd:simpleType>
CommonSimpleTypes INCLUDES the following name space definition:
Code:
<xsd:schema xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1" id="CommonSimpleTypes">
ContactTypes INCLUDES the follow definition
Code:
<xsd:schema targetNamespace="[URL unfurl="true"]http://www.parentcompany.com/people/AddressAndPersonalDetails"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] xmlns="[URL unfurl="true"]http://www.parentcompany.com/people/AddressAndPersonalDetails"[/URL] elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0" id="ContactTypes">
<xsd:include schemaLocation="CommonSimpleTypes-
v1.xsd"/>
<xsd:complexType name="TelephoneStructure">
<xsd:sequence>
<xsd:element name="TelNationalNumber" type="TelephoneNumberType"/>
<xsd:element name="TelExtensionNumber" type="TelephoneExtensionType" minOccurs="0"/>
<xsd:element name="TelCountryCode" type="TelCountryCodeType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="TelUse" type="WorkHomeType"/>
</xsd:complexType>
However, when validating in the text view in XML Spy, I get validation error The file is not valid: Schema error- undefined value for 'type' encounteredagainst the line
Code:
<xsd:element name="TelNationalNumber" type="TelephoneNumberType"/>
If I open MyFile.xsd in the Schema Design view and select validate, I get error The file is not valid:No Type with Name "TelephoneNumberType" has been defined in this or included/imported schemas in the ContactTypes Schema!
I think it MIGHT have something to do with the import/include for CommonSimpleTypes. However, if I take out the include for CommonSimpleTypes in MyFile.xsd, I get error when trying to use "RestrictedSimpleType".
What is wrong?