xml - XSD date format overriding -
I'm defining an XSD I need to define that element which takes the date in the format yyyymmdd i How can I define any restriction in XSD to accept this format only?
You always restrict it to a common type of string, based on a regular expression:
& lt; X: simple type name = "formatted type" & gt; & Lt; Xs: restriction base = "xs: string" & gt; & Lt; Xs: pattern value = "\ d {8}" /> & Lt; / XS: Ban & gt; & Lt; / XS: simpleType & gt;
If you really want to get smart, you can zoom in to regular expression even more for a date (for example, the environment is only 01 - 12 May be further):
& lt; X: simple type name = "formatted type" & gt; & Lt; Xs: restriction base = "xs: string" & gt; & Lt; Xs: pattern value = "\ d {4} (0 [1-9] | 1 [012]) (0 [1-9] | [12] [0-9] | 3 [01])" /> ; & Lt; / XS: Ban & gt; & Lt; / XS: simpleType & gt;
Mark
Comments
Post a Comment