XSD:在 2 个选项之间进行选择,可以同时选择两个选项

XSD: Choosing between 2 options with possibility to pick both

那么我能否以某种方式使下面的代码起作用?因此 XML 中必须存在选项 1 或选项 2,并且可以同时选择两者(但您不能同时拥有选项 1 或选项 2 中的 2 个)

<xsd:choice>
    <xsd:sequence>
        <xsd:element name="Option1" type="xsd:string" minOccurs="0"/>
        <xsd:element name="Option2" type="xsd:string"/>
    </xsd:sequence>
    <xsd:sequence>
        <xsd:element name="Option1" type="xsd:string"/>
        <xsd:element name="Option2" type="xsd:string" minOccurs="0"/>
    /xsd:sequence>
</xsd:choice>

你想要一个

  • 选项 1
  • 选项 2
  • 选项 1 和选项 2

这与其中一个相同

  • 选项 1,也许还有选项 2
  • 选项 2
<xsd:choice>
    <xsd:sequence>
        <xsd:element name="Option1" type="xsd:string"/>
        <xsd:element name="Option2" type="xsd:string" minOccurs="0"/>
    </xsd:sequence>
    <xsd:sequence>
        <xsd:element name="Option2" type="xsd:string"/>
    </xsd:sequence>
</xsd:choice>