Page 1 of 1

Please explain XPATH "Require XML element in XSD when another element has certain value?"

Posted: Fri Feb 16, 2018 6:39 pm
by mariomueller
Hi all,

on https://stackoverflow.com/questions/370 ... tain-value
I found an example for
"Require XML element in XSD when another element has certain value?"

In the solution is the XPATH:

Code: Select all

<xs:assert test="not(TYPE = 'INTERNATIONAL') or IBAN"/>
Could anybody please explain this? Why gets IBAN mandatory when TYPE = 'INTERNATIONAL'?
Many thanks
Regards
Mario

Re: Please explain XPATH "Require XML element in XSD when another element has certain value?"

Posted: Mon Feb 19, 2018 12:53 pm
by mariomueller
Hi,

i got it. OR is logical OR. Means: At least one expression must be true
When TYPE = 'INTERNATIONAL' the left side is false. So the right side 'IBAN' must be true.

<xs:assert test="not(TYPE = 'INTERNATIONAL') or IBAN"/>

Regards Mario

Re: Please explain XPATH "Require XML element in XSD when another element has certain value?"

Posted: Tue Feb 20, 2018 12:00 pm
by tavy
Hello,

Yes, the assert condition is satisfied even if the type is not 'INTERNATIONAL', or if the type is 'INTERNATIONAL' and you have an 'IBAN' element.

Best Regards,
Octavian