473,388 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 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 2258
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Group IIS | last post by:
Hi all, I am using ALTOVA XMLSpy. The start of my XML file looks like this: <?xml version="1.0" encoding="UTF-8" ?> <Submission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
4
by: stiank81 | last post by:
Hi. I have a problem witch I assume there is an answear to....? I have several XML schemas, and they all have quiet a lot of definitions in common. They still have to be seperated into...
3
by: MR | last post by:
Is there a way to load an XML schema into a dataset from a resource or other object? I am using ReadXmlSchema(filename) and that works fine. However, I have many XSD files that I would rather not...
1
by: Wallace | last post by:
Hi all, I have a problem on validating a xml fragment using a single namespace schema which spread across multiple schema files using include in the master schema file. No matter how I change...
1
by: Buggyman | last post by:
Hi, I'm having trouble validating an intranet URL. I'm using the regular expresssion validator (though any ideas accepted), and using the standard Internet URL definition, which is.....
4
by: Jonas Bush | last post by:
I've got the some code to try and validate some xml. Against my schema, the "Good" xml (below) produces a couple of warnings, which I don't care about. The "Bad" xml (also below), produces warnings...
2
by: josh | last post by:
Hi, I am trying to validate cXML documents against cXML.dtd using the XmlValidatingReader. If I set the XMLValidatingReader's ValidatingType to ValidationType.DTD, I get the following...
3
by: jh3an | last post by:
Please give me your advice! I made two files according to xml book, but when validating these two files, it gives me an error that I totally don't understand. Is there a problem in these...
9
by: bowlderyu | last post by:
Hello, all. I meet a question about compiling files. Eg., I have three files named myfile.h, myfile.c and the main.c file, and there is a function, ex, void myfun(...). If I put myfun(...) in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.