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.ReadXML Schema 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.ReadSch ema
would
1. Create table for "allowedObj ect" 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"
elementFormDefa ult="qualified" xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="ht tp://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:complexTy pe 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:complexTy pe 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:complexTy pe name="label">
<xs:complexCont ent>
<xs:extension base="control">
<xs:sequence>
<xs:element name="preferedH eight" type="xs:int" />
<xs:element name="preferedW idth" type="xs:int" />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:complexTy pe name="linkLabel ">
<xs:complexCont ent>
<xs:extension base="label">
<xs:sequence>
<xs:element name="link" type="xs:string " />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:complexTy pe name="textBox">
<xs:complexCont ent>
<xs:extension base="control">
<xs:sequence>
<xs:element name="maxLength " type="xs:int" />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:complexTy pe name="allowedOb ject">
<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:complexTy pe name="resource" >
<xs:sequence minOccurs="0" maxOccurs="unbo unded">
<xs:element name="allowedOb ject" type="allowedOb ject" />
</xs:sequence>
</xs:complexType>
<xs:element name="MyDataSet " type="resource" msdata:IsDataSe t="true" />
</xs:schema>