У меня есть эта схема
<xs:complexType name="FatherElement">
<xs:sequence>
<xs:element ref="FatherClass"/>
<xs:choice>
<xs:sequence>
<xs:element ref="FatherType"/>
<xs:element ref="FatherLocation" minOccurs="0"/>
<xs:element ref="FatherTypeDescription" minOccurs="0"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="FatherLocation"/>
<xs:element ref="FatherTypeDescription" minOccurs="0"/>
</xs:sequence>
<xs:element ref="FatherTypeDescription"/>
</xs:choice>
<xs:element ref="FatherBasis"/>
<xs:element ref="FatherRole" minOccurs="0"/>
<xs:element name="Extension" type="FatherElement_ExtensionType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
И я пытаюсь сопоставить с этим сопоставлением C # (было бы неплохо иметь все поля, но они мне сейчас не нужны)
[System.Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.lol.com/Standards/lol/1")]
public class FatherElement
{
/// <remarks/>
public string FatherTypeDescription { get; set; }
/// <remarks/>
public string FatherType { get; set; }
/// <remarks/>
public FatherLocation FatherLocation { get; set; }
}
[System.Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.lol.com/Standards/lol/1")]
public class FatherLocation
{
/// <remarks/>
public FatherLocationLocation Location { get; set; }
}
[System.Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.lol.com/Standards/lol/1")]
public class FatherLocationLocation
{
/// <remarks/>
public string Country { get; set; }
}
Входящее значение XML, которое я получаю:
<FatherElement>
<FatherClass>classValue</FatherClass>
<FatherType>typeValue</FatherType>
<FatherTypeDescription>typeValueDesc</FatherTypeDescription>
<FatherBasis>basisValue</FatherBasis>
<FatherRole>RoleValue</FatherRole>
</FatherElement>
А я выхожу:
<FatherElement>
<FatherTypeDescription>typeValueDesc</FatherTypeDescription>
<FatherType>typeValue</FatherType>
</FatherElement>
Когда я пытаюсь проверить его по SDC, я получаю сообщение об ошибке, в котором говорится, что элемент FatherElement имеет недопустимый дочерний объект FatherTypeDescription.
Я попытался сгенерировать отображение C # из XSD, но генерируемый им код преобразует варианты выбора в элемент объектов типа, и я хотел бы сохранить строгую типизацию.
Есть идеи?