문제

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