开发者

XSD Elements and enumerations

Considering an element which has an attribute. This attribute can have only values from a enumeration.

Is it possible to conditionnate the sons of this elements by the value of enumeration ?

There is an example, because my english is not very good :)

<xs:element minOccurs="0" n开发者_如何学Goame="datas">
<xs:complexType>
    <xs:sequence maxOccurs="unbounded">
        <xs:element maxOccurs="1" name="data">
            <xs:complexType>
                <xs:attribute name="tag" type="xs:string" use="required"/>
                <xs:attribute name="expr" type="xs:string" use="required"/>
                <xs:attribute name="format" use="required">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="choice1"/>
                            <xs:enumeration value="choice2"/>
                            <xs:enumeration value="choice3"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:attribute>
            </xs:complexType>
            <!-- HERE IS SOME SONS -->
            <xs:element name="element1" />
            <xs:element name="element2" />
            <xs:element name="element3" />
        </xs:element>
    </xs:sequence>
</xs:complexType>

If I choose "choice1", I would have element1 in required, and element2 / element3 in prohibited. If I choose "choice2", i would have element 2 in required, etc....

Do you know if is it possible ?

Thanks for the answer


This is a new feature in XSD 1.1 (currently supported in recent releases of Saxon and Xerces). It's a well-known restriction of XSD 1.0 that it can't do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜