我有以下内容:
<xs:complexType name="AnswerType">
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="Checklist" type="ChecklistType" />
<xs:element name="OptionList" type="OptionListType" />
<xs:element name="Measurement" type="MeasureType" />
</xs:choice>
</xs:complexType>
如何使用 SimpleXML 注释选择 XSD 元素?目前我必须将它们全部设置为 required=false
@Element(name = "Checklist", required=false)
protected ChecklistType checklist;
@Element(name = "OptionList", required=false)
protected OptionListType optionList;
@Element(name = "Measurement", required=false)
protected MeasureType measurement;
肯定有更好的办法。一个必须是 required=true 但如何?