Xml XSD生成器对选择项使用了错误的顺序

Xml XSD生成器对选择项使用了错误的顺序,xml,xsd,code-generation,xsd.exe,Xml,Xsd,Code Generation,Xsd.exe,使用XSD.exe/c/l:CS/o:temp/order时,它不会为Items[]数组中的选项生成正确的顺序 XSD: 在本例中,XSD为所有XmlElementAttribute生成Order=0,并按字母顺序排列。BItem2应该在AItem1之前 有没有办法让它正常工作?我无法更改XSD,因为它来自第三方。可能您可以使用和see@Rao我需要生成Csharp。我使用的是XmlSchemaImporter+XmlCodeExporter,它与XSD.exe相同,可能是的重复项 <xs

使用XSD.exe/c/l:CS/o:temp/order时,它不会为
Items[]
数组中的选项生成正确的顺序

XSD:

在本例中,XSD为所有XmlElementAttribute生成Order=0,并按字母顺序排列。BItem2应该在AItem1之前


有没有办法让它正常工作?我无法更改XSD,因为它来自第三方。

可能您可以使用和see@Rao我需要生成Csharp。我使用的是XmlSchemaImporter+XmlCodeExporter,它与XSD.exe相同,可能是的重复项
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xsd:group name="Group">
        <xsd:sequence>
            <xsd:element name="BItem2"/>
            <xsd:element name="AItem1"/>
        </xsd:sequence>
    </xsd:group>

    <xsd:element name="MyElement" type="MyClass"/>
    <xsd:complexType name="MyClass">
        <xsd:sequence>
            <xsd:choice>
                <xsd:element name="Whatever"/>
                <xsd:group ref="Group"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
    [System.Xml.Serialization.XmlElementAttribute("AItem1", typeof(object), Order=0)]
    [System.Xml.Serialization.XmlElementAttribute("BItem2", typeof(object), Order=0)]
    [System.Xml.Serialization.XmlElementAttribute("Whatever", typeof(object), Order=0)]
    [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
    public object[] Items {
       // ..
    }