Reputation: 7470
Is it possible to validate a custom datetime format with XML Schema? I want to validate element that contains a datetime that matches %Y%m%d%H%M%S
in strftime
format.
For example ISO 8601 datetime 2015-02-21T14:36:06
would be 20150221143606
.
Upvotes: 2
Views: 144
Reputation: 163595
Saxon has an extension facet saxon:preprocess that allows you (by means of an XPath expression) to convert your value before it is validated; this allows you to declare the type as xs:dateTime but in effect to define your own lexical representation of the values. Sadly this is non-standard, so it may not help you much.
Upvotes: 0
Reputation: 25054
Use XSD 1.1 and write an assertion that tests whether the data in your element can be used to construct a legal xsd:dateTime value; sub-string extraction functions and the dateTime constructor function will be your friends.
Upvotes: 2