Compare two dates in XSD 1.1?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 43
- Joined: Tue Jul 26, 2016 6:31 pm
Compare two dates in XSD 1.1?
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:
So, for example I would like to ensure that all values are earlier (less than) the , and that is always the same as or earlier (less) than (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:
Am I just getting the XPATHs wrong or is there something about the date format maybe?
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-update-date="2006-05-04T18:13:51.0Z"
last-renewal-date="2006-05-04T18:13:51.0Z" >
</Record>
<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">
</Event>
</Record>
</Records>
Code: Select all
issuance-date
Code: Select all
content-date
Code: Select all
last-renewal-date
Code: Select all
last-update-date
Here's an example of an assertion in the schema:
Code: Select all
<xs:assert id="plausibility-issuance-date-plausibility"
test="@issuance-date < ./@content-date"/>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Compare two dates in XSD 1.1?
Hi,
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?
Regards,
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?
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service