質問

a certain element of my xml data should match EXACT ONE of the following conditions:

1.) It has a @when attribute and nothing else.

2.) It has a @when-iso attribute and nothing else.

3.) It has both a @notBefore-iso and a @notAfter-iso attribute, but neither a @when nor a @when-iso attribute.

I try to test that using schematron, but I fail at creating a matching xpath expression.

I tried

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

but that doesn't work. Obviously, the content in brackets is simply ignored. So, how can I build complex/nested conditional expressions?

役に立ちましたか?

解決

An example that should work for your case :

<assert test="(@when and count(@*)=1) or (@when-iso and count(@*)=1) or (@notBefore-iso and @notAfter-iso and count(@*)=2)"/>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top