Reputation: 11
I am looking for a solution to the following case:
Suppose that you have 2 attributes in an XSD 1.1: "startDate" and "endDate". Suppose also that those are optional and you need to check if those are present or not. The following xsd shall work:
<complexType name="exampleType">
<attribute name="startDate" type="date" use="optional" />
<attribute name="endDate" type="date" use="optional" />
<assert test="(exists(@startDate) = exists(@endDate))"/>
</complexType>
What I would need is a way check that startDate is less or equal to endDate only in case both of them are provided. I have tried with those asserts:
<assert test="(exists(@startDate) = exists(@endDate)) and (@startDate le @endDate)"/>
<assert test="exists(@startDate) = (@startDate le @endDate)" />
But it does not work, when none of the attributes exist it provides a false because tries to execute the comparison.
Is it possible to check that both attributes exist before apply a comparison with Test? It would be very interesting to have the possibility to test something conditioned by a previous test.
Any help would be very appreciated.
Upvotes: 1
Views: 1572