By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,197 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,197 IT Pros & Developers. It's quick & easy.

question on "include" in schema files (.xsd). Trouble validating schema in .NET

P: n/a
Hi,

I hope someone can please help me. I'm having a lot of trouble with
schema files in .NET. I have produced a very simple example that uses
"include" to include other schema files. It all works with SPY, but
when I pick "Validate Schema" from the .NET 2003 menu, it fails with
message:

"Type XType is not declared." As I hinted at in my subject line, I
suspect that it has to do with including another schema multiple times.
Can someone tell me how this should be done? Possibly, SPY or .NET do
not conform to the standard. Is there a reference somewhere to this.
I'm somewhat at others mercy as the schema files are given to us by a
third party that claims, "hey they work with SPY!". If I can come up
with a specific solution though, I can probably force them to comply.

Here are the scema files. Notice I include Common_dataTypes.xsd in the
main schema AND I include it in common_PointRecord.xsd
which is itself included in RecordOfInterest.xsd
which is in turn included in main.xsd. Again, I suspect that include
files twice is the real problem. Is there a limit or rule on multiple
includes of schema files?

Any help would be greatly appreciated.

Thanks,

Andrew

main.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://test/schemas"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/schemas" elementFormDefault="qualified">
<xsd:include schemaLocation="Common_dataTypes.xsd"/>
<xsd:include schemaLocation="RecordOfInterest.xsd"/>
<xsd:element name="PRIMARY_QUERY">
<xsd:complexType>
<xsd:all>
<xsd:element name="Id" type="standardIdentifierType"/>
<xsd:element name="RecordOfInterestobj" type="RecordOfInterest"
minOccurs="0"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>

commonDataTypes.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:simpleType name="XType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="-10.0"/>
<xsd:maxInclusive value="10.0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="YType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="-18.0"/>
<xsd:maxInclusive value="18.0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="standardIdentifierType">
<xsd:restriction base="xsd:token">
<xsd:maxLength value="128"/>
<xsd:minLength value="1"/>
<xsd:pattern value="[0-9A-Za-z_\.\-]+"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
RecordOfInterest.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://test/schemas"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/schemas" elementFormDefault="qualified">
<xsd:include schemaLocation="common_PointRecord.xsd"/>
<xsd:complexType name="RecordOfInterest">
<xsd:all>
<xsd:element name="DATA">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="TempData" type="PointRecord" minOccurs="3"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:schema>

common_PointRecord.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:include schemaLocation="Common_dataTypes.xsd"/>
<xsd:complexType name="PointRecord">
<xsd:all>
<xsd:element name="X" type="XType">
</xsd:element>
<xsd:element name="Y" type="YType">
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:schema>

Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
This is a known issue regarding chameleon includes in .net framework 1.1.
This is fixed .net framework 2.0 in the new schema store - XmlSchemaSet.

Thanks,
Zafar

<bi*********@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,

I hope someone can please help me. I'm having a lot of trouble with
schema files in .NET. I have produced a very simple example that uses
"include" to include other schema files. It all works with SPY, but
when I pick "Validate Schema" from the .NET 2003 menu, it fails with
message:

"Type XType is not declared." As I hinted at in my subject line, I
suspect that it has to do with including another schema multiple times.
Can someone tell me how this should be done? Possibly, SPY or .NET do
not conform to the standard. Is there a reference somewhere to this.
I'm somewhat at others mercy as the schema files are given to us by a
third party that claims, "hey they work with SPY!". If I can come up
with a specific solution though, I can probably force them to comply.

Here are the scema files. Notice I include Common_dataTypes.xsd in the
main schema AND I include it in common_PointRecord.xsd
which is itself included in RecordOfInterest.xsd
which is in turn included in main.xsd. Again, I suspect that include
files twice is the real problem. Is there a limit or rule on multiple
includes of schema files?

Any help would be greatly appreciated.

Thanks,

Andrew

main.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://test/schemas"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/schemas" elementFormDefault="qualified">
<xsd:include schemaLocation="Common_dataTypes.xsd"/>
<xsd:include schemaLocation="RecordOfInterest.xsd"/>
<xsd:element name="PRIMARY_QUERY">
<xsd:complexType>
<xsd:all>
<xsd:element name="Id" type="standardIdentifierType"/>
<xsd:element name="RecordOfInterestobj" type="RecordOfInterest"
minOccurs="0"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>

commonDataTypes.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:simpleType name="XType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="-10.0"/>
<xsd:maxInclusive value="10.0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="YType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="-18.0"/>
<xsd:maxInclusive value="18.0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="standardIdentifierType">
<xsd:restriction base="xsd:token">
<xsd:maxLength value="128"/>
<xsd:minLength value="1"/>
<xsd:pattern value="[0-9A-Za-z_\.\-]+"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
RecordOfInterest.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://test/schemas"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/schemas" elementFormDefault="qualified">
<xsd:include schemaLocation="common_PointRecord.xsd"/>
<xsd:complexType name="RecordOfInterest">
<xsd:all>
<xsd:element name="DATA">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="TempData" type="PointRecord" minOccurs="3"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:schema>

common_PointRecord.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:include schemaLocation="Common_dataTypes.xsd"/>
<xsd:complexType name="PointRecord">
<xsd:all>
<xsd:element name="X" type="XType">
</xsd:element>
<xsd:element name="Y" type="YType">
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:schema>

Nov 12 '05 #2

P: n/a
Zafar,

Thanks for the response.

Can you give me an example of how to fix the problem? I did some
checking, and the term "targetNamespace" came up. I tried adding the
same targetNamespace to all child schemas without success. That is, I
added "targetNamespace="http://test/schemas"" to all the schemas. Is
there something else I need to do?

Thank you,

Andrew

Nov 12 '05 #3

P: n/a
Add this to the xs:schema element in the common_PointRecord.xsd schema.

targetNamespace="http://test/schemas" xmlns="http://test/schemas"

-Zafar
<bi*********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Zafar,

Thanks for the response.

Can you give me an example of how to fix the problem? I did some
checking, and the term "targetNamespace" came up. I tried adding the
same targetNamespace to all child schemas without success. That is, I
added "targetNamespace="http://test/schemas"" to all the schemas. Is
there something else I need to do?

Thank you,

Andrew

Nov 12 '05 #4

P: n/a
Thanks Zafar!

That works.

Andrew

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.