Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XPath:嵌套/复杂条件_Xpath_Conditional Statements_Schematron - Fatal编程技术网

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)

我的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)">


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

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

<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)"/>