1

我的 xml 数据的某个元素应符合以下条件之一:

1.) 它有一个@when 属性,没有别的。

2.) 它有一个 @when-iso 属性,没有别的。

3.) 它同时具有@notBefore-iso 和@notAfter-iso 属性,但既没有@when 也没有@when-iso 属性。

我尝试使用 schematron 进行测试,但无法创建匹配的 xpath 表达式。

我试过了

<assert test="@when or @when-iso or (not(@when) and not(@when-iso) and @notBefore-iso and @notAfter-iso)">

但这不起作用。显然,括号中的内容被简单地忽略了。那么,如何构建复杂/嵌套的条件表达式?

4

1 回答 1

4

一个应该适用于您的案例的示例:

<assert test="(@when and count(@*)=1) or (@when-iso and count(@*)=1) or (@notBefore-iso and @notAfter-iso and count(@*)=2)"/>
于 2013-12-09T16:51:41.273 回答