can we specify MM-DD-YYYY format date restriction in XSD on element which we want to restrict ?
+1
A:
Yes it is possible with an regex
<xsd:simpleType name="Date">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{2}-\d{2}-\d{4}"/>
</xsd:restriction>
</xsd:simpleType>
Left is of course that the range should be checked also. Maybe you can extend the regex to only accept certain numbers.
schoetbi
2010-08-17 21:28:04
with the above pattern 30-30-2010 is also valid right, is there any way that i can restrict valid date only ?
Laxmikanth Samudrala
2010-08-17 21:37:50
Maybe this could be done with a schematron http://en.wikipedia.org/wiki/Schematron rule but I am not familiar with this.
schoetbi
2010-08-17 21:48:29
+1
A:
Yes, with a pattern restriction on a string.
On a machine-readable format I'd advise using the International standard (which is also your national standard ANSI X3.30) as it is expected, widely supported and well known.
If it's intended to be displayed to a human directly rather than processed by the consuming machine, the a local convetion is fine, though it's important to be clear that it's being used.
Jon Hanna
2010-08-17 21:33:51