XML模式:扩展xsd:choice,以便创建选项的联合(而不是序列)

XML模式:扩展xsd:choice,以便创建选项的联合(而不是序列),xsd,choice,Xsd,Choice,我有以下XML模式 <xsd:complexType name="SimpleThing"> <xsd:choice maxOccurs="unbounded"> <xsd:group ref="simpleContent" /> </xsd:choice> </xsd:complexType> <xsd:complexType name="ExtendedThing"> <x

我有以下XML模式

<xsd:complexType name="SimpleThing">
    <xsd:choice maxOccurs="unbounded">
        <xsd:group ref="simpleContent" />
    </xsd:choice>
</xsd:complexType>

<xsd:complexType name="ExtendedThing">
    <xsd:complexContent>
        <xsd:extension base="SimpleThing">
            <xsd:choice maxOccurs="unbounded">
                <xsd:element name="qux" />
            </xsd:choice>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

<xsd:group name="simpleContent">
    <xsd:choice>
        <xsd:element name="foo" />
        <xsd:element name="bar" />
    </xsd:choice>
</xsd:group>

<xsd:group name="extendedContent">
    <xsd:choice>
        <xsd:group ref="simpleContent" />
        <xsd:element name="qux" />
    </xsd:choice>
</xsd:group>

<xsd:element name="root" type="ExtendedThing" />
也不起作用,因为违反了约束


这个问题有什么解决方案吗?或者不可能在XML模式中创建一个类型,该类型是另一个类型的扩展,因此新类型的内容是一组元素(以任何顺序),这些元素是超类型内容的超集?

出于实际原因,这是不可能的。超级类型的内容模型必须始终位于子类型的内容模型之前。它有助于快速实现验证器。

请参阅:
<xsd:complexType name="ExtendedThing">
    <xsd:complexContent>
        <xsd:extension base="SimpleThing">
            <xsd:group ref="extendedContent" />
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>