A
Anders Ljusberg
Hi!
I have a problem.. I'm trying to get the XML from a
dataset to conform to an XSD, but it keeps rearranging
some elements.
Try this schema:
<xs:schema id="test"
targetNamespace="http://tempuri.org/test.xsd"
xmlns:mstns="http://tempuri.org/test.xsd"
xmlns="http://tempuri.org/test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:complexType name="testType1">
<xs:sequence>
<xs:element name="nestedElement"
type="mstns:testType2" minOccurs="0"
maxOccurs="unbounded" />
<xs:element name="testInt" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="testType2">
<xs:sequence>
<xs:element name="testString" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="testElement" type="mstns:testType1" />
<xs:element name="test" msdata:IsDataSet="true"
msdata:Locale="sv-SE">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="testElement" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I create a DataSet from this schema (by using
ReadXmlSchema), and then I call the GetXmlSchema method.
The result is ALMOST the same, with the difference that
the first sequence has changed. It now looks like this:
<xs:sequence>
<xs:element name="testInt" type="xs:int" />
<xs:element name="nestedElement"
type="mstns:testType2" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
Why is this? It seems like simple types always comes ahead
of complex types. Is it by design or is it a bug?
/Anders
I have a problem.. I'm trying to get the XML from a
dataset to conform to an XSD, but it keeps rearranging
some elements.
Try this schema:
<xs:schema id="test"
targetNamespace="http://tempuri.org/test.xsd"
xmlns:mstns="http://tempuri.org/test.xsd"
xmlns="http://tempuri.org/test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:complexType name="testType1">
<xs:sequence>
<xs:element name="nestedElement"
type="mstns:testType2" minOccurs="0"
maxOccurs="unbounded" />
<xs:element name="testInt" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="testType2">
<xs:sequence>
<xs:element name="testString" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="testElement" type="mstns:testType1" />
<xs:element name="test" msdata:IsDataSet="true"
msdata:Locale="sv-SE">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="testElement" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I create a DataSet from this schema (by using
ReadXmlSchema), and then I call the GetXmlSchema method.
The result is ALMOST the same, with the difference that
the first sequence has changed. It now looks like this:
<xs:sequence>
<xs:element name="testInt" type="xs:int" />
<xs:element name="nestedElement"
type="mstns:testType2" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
Why is this? It seems like simple types always comes ahead
of complex types. Is it by design or is it a bug?
/Anders