I have read that we can use minInclusive and maxInclusive restrictions on xsd:datetime fields. But how can I make sure that my dateTime field shall not occur more than 5 minutes into the future? I know how to handle it in java . But I want the validation at the schema level. Please help me.
Asked
Active
Viewed 265 times
1 Answers
2
This can be done using XSD 1.1. Example:
<xs:element name="myDateTime">
<xs:simpleType>
<xs:restriction base="xs:dateTime">
<xs:assertion test="$value lt (current-dateTime() + xs:dayTimeDuration('PT5M'))"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Explantion:
current-dateTime() + xs:dayTimeDuration('PT5M')
sums 5 minutes to current date.
lt
stands for lower than as the character <
cannot be used at that part.
$value
holds the value in an XSD 1.1 assertion.
See also: xs:dayTimeDuration at XPath 2.0 specs

sergioFC
- 5,926
- 3
- 40
- 54