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

This should cover W3C XML Schema, Relax NG and DTD related problems.
mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post by mariomueller » Fri Feb 16, 2018 6:39 pm

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

mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post by mariomueller » Mon Feb 19, 2018 12:53 pm

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

tavy
Posts: 188
Joined: Thu Jul 01, 2004 12:29 pm

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

Post by tavy » Tue Feb 20, 2018 12:00 pm

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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply