0

属性を持つ要素を考えます。この属性は、列挙からの値のみを持つことができます。

列挙の値によってこの要素の息子を条件付けすることは可能ですか?

私の英語はあまり上手ではないので、例があります:)

<xs:element minOccurs="0" name="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>

「choice1」を選択すると、element1が必須になり、element2/element3が禁止になります。「choice2」を選択すると、必須の要素2などが含まれます。

それが可能かどうか知っていますか?

答えてくれてありがとう

4

1 に答える 1

1

これはXSD1.1の新機能です(現在、SaxonおよびXercesの最近のリリースでサポートされています)。これを実行できないことは、XSD1.0のよく知られた制限です。

于 2011-08-25T16:38:47.963 に答える