XPath:嵌套/复杂条件
我的xml数据的某个元素应与以下条件之一完全匹配: 1.)它有一个@when属性,没有其他属性 2.)它有一个@when iso属性,没有其他属性 3.)它同时具有@notBefore iso和@notAfter iso属性,但既没有@when也没有@when iso属性 我尝试使用schematron测试这一点,但未能创建匹配的xpath表达式 我试过了XPath:嵌套/复杂条件,xpath,conditional-statements,schematron,Xpath,Conditional Statements,Schematron,我的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)
<assert test="@when or @when-iso or (not(@when) and not(@when-iso) and @notBefore-iso and @notAfter-iso)">
但这不起作用。显然,括号中的内容被忽略了。那么,我如何构建复杂/嵌套的条件表达式呢?一个适用于您的案例的示例:
<assert test="(@when and count(@*)=1) or (@when-iso and count(@*)=1) or (@notBefore-iso and @notAfter-iso and count(@*)=2)"/>
一个适用于您的案例的示例:
<assert test="(@when and count(@*)=1) or (@when-iso and count(@*)=1) or (@notBefore-iso and @notAfter-iso and count(@*)=2)"/>