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

Problem creating DataSet structure from xsd: The same table (...) cannot be the child table in two nested relations.

P: n/a
Max
Suppose we have an object hierarchy in XSD.
For example, let us take Control, Label, TextBox and LinkLabel windows
controls.
Each control has some properties which are represented as elements.
Some of the elements are of complex types as well, like bounds - of type
rectangle.
(See full example in the bottom of the letter.)

DataSet.ReadXMLSchema fails to parse such XSD file.
The problem is caused by complex type as an element of the base type of
hierarchy.
(In the example this type is called rectangle.)
More specifically, when parsing the example XSD file DataSet.ReadSchema
would
1. Create table for "allowedObject" complex type.
2. Create table named "label" for label complex type.
3. Create table "bounds" for bounds element of complex type "rectangle".
4. Create table "textBox" for textBox complex type.
5. Try to create "bounds" table for bounds element of complex type
"rectangle" and fail because this table already exists.

From my point of view is a serious restriction of functionality.
I am using Visual Studio 2002 and .NET Framework 1.0.
Is it fixed in Framework 1.1?

Can you think of a workaround for this problem?
Please do not suggest to inherit control from rectangle, because in real
schema I have more then one complex property.
I can add "font" to this example to illustrate it.

Thank you.
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:complexType name="rectangle">
<xs:sequence>
<xs:element name="left" type="xs:int" />
<xs:element name="top" type="xs:int" />
<xs:element name="width" type="xs:int" />
<xs:element name="height" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="control">
<xs:sequence>
<xs:element name="bounds" type="rectangle" />
<xs:element name="name" type="xs:string" />
<xs:element name="text" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="label">
<xs:complexContent>
<xs:extension base="control">
<xs:sequence>
<xs:element name="preferedHeight" type="xs:int" />
<xs:element name="preferedWidth" type="xs:int" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="linkLabel">
<xs:complexContent>
<xs:extension base="label">
<xs:sequence>
<xs:element name="link" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="textBox">
<xs:complexContent>
<xs:extension base="control">
<xs:sequence>
<xs:element name="maxLength" type="xs:int" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="allowedObject">
<xs:choice>
<xs:element name="label" type="label" />
<xs:element name="textBox" type="textBox" />
<xs:element name="linkLabel" type="linkLabel" />
</xs:choice>
</xs:complexType>
<xs:complexType name="resource">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="allowedObject" type="allowedObject" />
</xs:sequence>
</xs:complexType>
<xs:element name="MyDataSet" type="resource" msdata:IsDataSet="true" />
</xs:schema>
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.