-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence order not maintained when choice is between B or A+B #285
Comments
This is due to the way XmlSchemaClassGenerator handles choice elements. It might seem as if the order is wrong, but the The situation would be different if there weren't two elements both named I don't see a way out of this while keeping the current way of dealing with choice elements. Perhaps, if it's feasible within your project, it might be an option to modify the schema so that XmlSchemaClassGenerator generates code that allows for XML that is compatible with the original schema. AFAICT, this should be equivalent: <xsd:element name="someClass">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="someElement" type="xsd:string"/>
<xsd:element name="primary" type="subClass" minOccurs="0" />
<xsd:element name="secondary" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element> |
What if XmlSchemaClassGenerator added I ended up adding the |
It's not an order-related issue. The order is already correct, it's just that the second The default order of elements in a sequence is simply the enumeration order of |
Problem
Given a schema where there's a
choice
between enteringB
or a sequence ofA
+B
, the order of the sequence is not maintained in the generated xml even with--order
. The--order
appends theOrder
attributes in the wrong order.How to reproduce
Schema example:
Example C# code:
Resulting xml:
Expected result
Because I have entered both fields
Primary
andSecondary
, I have effectively picked the second option of thechoice
which is asequence
and its order should be maintained. I would thus expect the resulting xml to be:The text was updated successfully, but these errors were encountered: