问题描述
对于另一个纸牌游戏,我应该设计一个元素,该元素仅在较早位置的属性具有任何值时才使用,其中包含子字符串“Count”,如本例所示:
<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>
我的问题是:如何根据元素“type”中的属性“condition”使用元素“count”,在其值中包含单词“Count”?我已经尝试使用以下断言来解决它,但它似乎有一个错误的表达式(至少它没有编译):<xs:assert test="if (type/@condition contains('Count')) then (count) else not(count)"/>
那么我如何在 xml 方案中表达以下 if 语句:
if (type.condition.contains('Count') then required(count) else don't use(count))
解决方法
您可以测试 type/@condition
值是否包含谓词内的单词 Count
,然后如果它包含 count
元素是否存在,否则返回 {{1} }.
true()