XML模式限制可以选择的类型

问题描述

我试图创建一个受限类型,其中基本类型在选择中包含一长串元素,而我的受限类型仅包含这些元素的子集:

<xs:complexType name="AD" mixed="true">
    <xs:complexContent>
        <xs:extension base="ANY">
            <xs:sequence>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="delimiter" type="adxp.delimiter"/>
                    <xs:element name="country" type="adxp.country"/>
                    <xs:element name="state" type="adxp.state"/>
                    <xs:element name="county" type="adxp.county"/>
                    <xs:element name="city" type="adxp.city"/>
                    <xs:element name="postalCode" type="adxp.postalCode"/>
                    <xs:element name="addressLine" type="adxp.addressLine"/>
                    <xs:element name="streetAddressLine" type="adxp.streetAddressLine"/>
                    <xs:element name="houseNumber" type="adxp.houseNumber"/>
                </xs:choice>
            </xs:sequence>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

<xs:complexType name="Simple-AD">
    <xs:complexContent>
        <xs:restriction base="AD">
            <xs:sequence>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="country" type="adxp.country"/>
                    <xs:element name="state" type="adxp.state"/>
                    <xs:element name="city" type="adxp.city"/>
                    <xs:element name="postalCode" type="adxp.postalCode"/>
                    <xs:element name="streetAddressLine" type="adxp.streetAddressLine"/>
                </xs:choice>
            </xs:sequence>
        </xs:restriction>
    </xs:complexContent>
</xs:complexType>

这似乎是一件合理的事情,但是我收到了可怕的“禁止粒子限制:'choice:all,sequence,elt'”验证错误。根据我对Schema验证规则的阅读,似乎它应该验证(https://www.w3.org/TR/xmlschema-1/#rcase-RecurseLax),但不是。

是否不可能在模式类型限制中限制选择集?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)