471,594 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

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

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
4 2134
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
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
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
Thanks Zafar!

That works.

Andrew

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Group IIS | last post: by
4 posts views Thread by stiank81 | last post: by
3 posts views Thread by MR | last post: by
1 post views Thread by Buggyman | last post: by
4 posts views Thread by Jonas Bush | last post: by
9 posts views Thread by bowlderyu | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.