0
Answer

ReadXmlSchema and WriteXmlSchema discrepancy problem?

Sy

Sy

17y
3.7k
1

I need some help to solve this issue. I have a schema file called "a.xsd". I used new DataSet to read it using ReadXmlSchema  and save it right away using WriteXmlSchema method without doing any data input. The new saved schema "b.xsd" is different from "a.xsd". Especially, it changes the sequence of the elements. It makes my output xml file not compliant with my original schema. I searched web and found nothing related. Please help and tell me if this is bug or something I missed. Thanks a lot.

Two schema files are listed below:

=== a.xsd ===

 

<?xml version="1.0" standalone="yes"?>

<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified" id="Results">

<xs:element name="Results" msdata:IsDataSet="true">

<xs:complexType>

<xs:choice maxOccurs="unbounded">

<xs:element name="Requisitions">

<xs:complexType>

<xs:sequence>

<xs:element name="Requisition" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>

<xs:element name="Message" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:choice>

</xs:complexType>

</xs:element>

</xs:schema>

 

==== b.xsd ====

<?xml version="1.0" standalone="yes"?>

<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" id="Results">

<xs:element name="Results" msdata:IsDataSet="true">

<xs:complexType>

<xs:choice maxOccurs="unbounded">

<xs:element name="Requisitions">

<xs:complexType>

<xs:sequence>

<xs:element name="Message" type="xs:string"/>

<xs:element name="Requisition" nillable="true" minOccurs="0" maxOccurs="unbounded">

<xs:complexType>

<xs:simpleContent>

<xs:extension base="xs:string"/>

</xs:simpleContent>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:choice>

</xs:complexType>

</xs:element>

</xs:schema>