We're using LinqToXSD in our project and we're trying to figure out the "right way" to use LinqToXSD's implementation of the xs:choice element.
The following schema tried to implement a list of types that all inherit from a base type:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Items" type="Shell"/>
<xs:element name="List" type="Item"/>
<xs:element name="SubItem" type="SubItem"/>
But the LinqToXSD implementation of an Shell is bizarre. It contains two properties, one for Item and one for SubItem.
It's really us trying to get around the limitation of Schema not allowing us to create sequences of the base type Item, while also allowing the extended type SubItem in the list. It just doesn't allow polymorphism.
The closes I've ever found is this example: http://www.datypic.com/books/defxmlschema/chapter14.html
Which I used to create the above schema.
In the above schema, in order to preserve the ordering of the elements I wrap the choice in a Shell type.
In the linked document, they have an unbounded choice element.
This unbounded choice creates a class with one IList<T> of each of the allowed choices.
How are you supposed to extract the sequencing information from this? How to I tell which order the elements are added to the document?