Page 1 of 1

Compare two dates in XSD 1.1?

Posted: Wed Mar 08, 2017 12:14 pm
by mhGLEIF
I want to write a number of assertions to compare pairs of dates in XSD 1.1 but it's not working.

Can someone help me get started?

Here's a couple of examples:

Code: Select all

<Records content-date="2006-05-04T18:13:51.0Z">

    <Record  issuance-date="2006-05-04T18:13:51.0Z"
         last-renewal-date="2006-05-04T18:13:51.0Z" >
    <Record issuance-date="2006-05-04T18:13:51.0Z"
         last-update-date="2006-05-04T18:13:51.0Z" last-renewal-date="2006-05-04T18:13:51.0Z">
        <Event event-date="2006-05-04T18:13:51.0Z" event-type="INITIAL_REGISTRATION">

So, for example I would like to ensure that all

Code: Select all

values are earlier (less than) the

Code: Select all

, and that

Code: Select all

is always the same as or earlier (less) than

Code: Select all

(maybe the last update to the record *was* to renew its registration, but the renewal can't happen *without* an update timestamp.

Here's an example of an assertion in the schema:

Code: Select all

<xs:assert id="plausibility-issuance-date-plausibility"
            test="@issuance-date &lt; ./@content-date"/>

Am I just getting the XPATHs wrong or is there something about the date format maybe?

Re: Compare two dates in XSD 1.1?

Posted: Mon Mar 13, 2017 7:06 pm
by adrian

The problem is not that they are dates, the problem is in what context you place the assert and what XPath you can use in that context.
AFAIK, you can't use XPath to look outside of the branch (up the hierarchy) you are in. So, if you place the assert within an element or type, you can't use XPath to point to an ancestor of that element or type, you can only point to it and its children.

So where is your assert placed?