Just as listed in the Unsupported section, Choice Elements with a MaxOccurance attribute set are currently not working. However worse than simply not working is that they quietly produce a different serialization from what you'd expect.
Currently, it produces a dedicated Collection type for each Choice Element. Through this you can parse XML files and you can also serialize your own but only if the order of the elements are irrelevant... which they probably aren't.
For reference, if I create classes for this schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="ns://test" targetNamespace="ns://test" elementFormDefault="qualified">
<xsd:element name="container">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element ref="MemA"/>
<xsd:element ref="MemB"/>
<xsd:element ref="MemC"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="MemA">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="MemB">
<!--same as MemA-->
</xsd:element>
<xsd:element name="MemC">
<!--same as MemA-->
</xsd:element>
</xsd:schema>
The old xsd.exe or xsd2code.exe would produce something like this. And although it lacks proper type-safety it at least correctly preserves the actual order of elements.
[System.Xml.Serialization.XmlArrayItemAttribute("MemA", typeof(MemA), IsNullable = false)]
[System.Xml.Serialization.XmlArrayItemAttribute("MemB", typeof(MemB), IsNullable = false)]
[System.Xml.Serialization.XmlArrayItemAttribute("MemC", typeof(MemC), IsNullable = false)]
public object[] container { get; set; }
Trying to parse something like this would give me a single list of MemA, then MemC, then MemC, while the current version of xscgen has no way of discovering or mapping the intended order.
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="ns://test">
<MemA>TestA</MemA>
<MemC>TestC</MemC>
<MemB>TestB</MemB>
</container>
It's a real shame since this tool has many great capabilities that I would otherwise like to use but can't since preserving the order of such choice elements is a strict requirement.
Just as listed in the
Unsupportedsection, Choice Elements with a MaxOccurance attribute set are currently not working. However worse than simply not working is that they quietly produce a different serialization from what you'd expect.Currently, it produces a dedicated Collection type for each Choice Element. Through this you can parse XML files and you can also serialize your own but only if the order of the elements are irrelevant... which they probably aren't.
For reference, if I create classes for this schema:
The old xsd.exe or xsd2code.exe would produce something like this. And although it lacks proper type-safety it at least correctly preserves the actual order of elements.
Trying to parse something like this would give me a single list of MemA, then MemC, then MemC, while the current version of xscgen has no way of discovering or mapping the intended order.
It's a real shame since this tool has many great capabilities that I would otherwise like to use but can't since preserving the order of such choice elements is a strict requirement.