1
我有下面的XML(例如SNIPPIT)的情况:XML断言为子属性基于父属性
<foo type="color">
<bar choice="red"/>
<bar choice="blue"/>
</foo>
<foo type="shape">
<bar choice="circle"/>
<bar choice="square"/>
</foo>
从本质上讲,我想限制的可能值基于属性“选择”父属性“type”的值。我知道断言不会让我看父母的价值,但我认为它应该让我看看孩子的价值观。这意味着我需要将父级别置于父级别,但我不确定将如何写入这些子级属性。如果他们在相同的元素,它会是这样的:
<assert test="(@type='color' and @choice=('red','blue')) or (@type='shape' and @choice=('circle','square'))"/>
或者我完全脱离基地?