I'm using XSD 1.1 to validate incoming XML. I have an assert that works properly except when the values are null.
Here's the test:
<xs:assert test="ELEM1 = ' ' and ELEM2 = ' '
or ELEM1 != ' ' and matches(ELEM2, '.*')"/>
Here's what the XML in question shows:
<ELEM1 />
<ELEM2 />
I've tried "is null", "is nil", "= null", "= nil", but nothing seems to work.
How do I test for a null element?
Terminology note: The elements, ELEM1 and ELEM2, are generally referred to as being empty rather than having null values.
This xs:assert,
<xs:assert test="ELEM1[not(node())] and ELEM2[not(node())] "/>
says that there must be two empty child elements, ELEM1 and ELEM2.