xsd - How to validate DD MM YYYY date with XML Schema? -
i trying validate date format 23 december 2012
date format xml schema using type="xsd:date"
cvc-datatype-valid.1.2.1: '23 december 2012' not valid value 'date'.. line '12', column '53'.
element example:
<datereleased>23 december 1966</datereleased>
schema example:
<xsd:element name="datereleased" type="xsd:date" />
is possible using type
attribute (xs:date
)? or, need use xs:pattern
instead?
you cannot redefine format accepted xs:date
in xsd.
you use xs:pattern
regex constraints close, won't able capture full date semantics (day ranges months, leap years, etc).
if have control on date formats, go standard 1 supported xsd. if not, consider transforming xml via xslt, has more flexibility in defining date formats, ahead of validation.
Comments
Post a Comment