Ogranicz wartość atrybutu w zależności od wartości innego atrybutu

Rozważ to XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Test">
        <xs:complexType>
            <xs:attribute name="X">
                <xs:simpleType>
                    <xs:restriction>
                        <xs:enumeration value="One"/>
                        <xs:enumeration value="Two"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Y">
                <xs:simpleType>
                    <!-- Choose how to restrict the value based on the value of the X attribute. -->
                    <xs:restriction base="if X=One then List1 else List2"/>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="List1">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Option1"/>
            <xs:enumeration value="Option2"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="List2">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Option3"/>
            <xs:enumeration value="Option4"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Więc dla atrybutuTest/@Y, Chcę ograniczyć możliwe wartości na podstawie wartościTest/@X. JeśliX jestOne, następnieY może być w środkuList1, Inaczej,Y musi byćList2. czy to możliwe?

questionAnswers(1)

yourAnswerToTheQuestion