XSD none,一个,或两个

XSD none, one, or both

我搜索了一大堆,在发布之前找不到与此类似的问题。我正在努力创建一个 XSD 并且一个 complexType 具有以下要求:

它基本上可以 "none, one(but a specific one), or both" 但我无法弄清楚我做错了什么,我们将不胜感激

<xs:complexType name="Foo">
    <xs:choice minOccurs="0">
        <xs:sequence>
            <xs:element name="fieldOne" maxOccurs="1"/>
        </xs:sequence>
        <xs:sequence>
            <xs:element name="fieldOne" maxOccurs="1"/>
            <xs:element name="fieldTwo" maxOccurs="1"/>             
        </xs:sequence>
    </xs:choice>
</xs:complexType>

您可以使用可选序列执行此操作:

<xs:complexType name="Foo">
    <xs:sequence minOccurs="0">
        <xs:element name="fieldOne"/>
        <xs:element name="fieldTwo" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>

出现 fieldTwo 的唯一方法是序列出现一次,在这种情况下也需要 fieldOne