dimanche 10 janvier 2021

XSD 1.1: Restrict use of an element to another attribute having a certain substring

For another of card-game I am supposed to design an element that is only being used when an attribute in an earlier place has any value, that contain the substring "Count" as seen in this example:

    <card>
        <type condition="numberCount" until="3">Draw</type>
        <text>Draw one card for any new card on the field with a value not being 2 in the next 3 upcoming rounds.</text>
        <count>-2</count>
    </card>

My question is: How do I make the use of the element "count" dependent on the attribute "condition" in the element "type" having the word "Count" inside its value? I already tried to solve it by using the following assert but it seems to have a wrong expression (at least it's not compiling): <xs:assert test="if (type/@condition contains('Count')) then (count) else not(count)"/>

So how do I express the following if-statement in an xml scheme:

if (type.condition.contains('Count') then required(count) else don't use(count))

Aucun commentaire:

Enregistrer un commentaire