Re: Change of Date pattern in XML Schema

Raju MP:

>> I need to validate the Date format CCYYMMDD which is
>> different from the ISO 8601 Date format CCYY-MM-DD.
>> How can I do this validation in the XMLSchema by using
>> W3C Date datatype.

The short answer is that you cannot validate it as a date.  You can, of 
course, make subtypes of string (or token if you prefer) that will 
recognize the pattern, but they will not be considered to be dates, and 
won't benefit from the associated range checking facets such as 
minInclusive/maxInclusive.

The fact is that building date types that would meet everyone's needs is a 
daunting, perhaps impractical task.  In various parts of the world, 
different calendars and conventions and used.  These can be as simple as 
locales in the same country that adopt anomolous daylight saving 
conventions, and include such very deep issues as lunar vs. solar 
calendars.  How do you compare a lunar to a solar date?  Of course, that's 
before you get to the potentially simpler problem of your request, which 
is that there is a tremendous variety in the conventions used to represent 
even the same date. 

We eventually considered two fundamental approaches.  One would have 
allowed users to build their own date types, by writing code to do the 
validation, range checking etc.  In general, schema has avoided any 
feature that involves pluggable code, as such features tend not to 
interoperate.  If I write my date type validator as a Java bean, can you 
run it in .Net?  In Cobol?  The other alternative is the one we chose: 
which is to implement a single date/time convention, based on a standard 
(ISO 8601) that is admittedly centered on Western solar calendars, but 
that would at least make possible a fairly broad range of computer 
applications.  If your dates are stored in some other form (binary, 
CCYYMMDD, whatever) you will have to convert them if you want to use the 
Schema data types.

I don't speak officially for the Schema WG, but I think this is a fairly 
good summary of how we wound up with the date/time features in the current 
language.  I hope it explains the reasons for our lack of support of the 
format that you have requested.

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------

Received on Tuesday, 25 February 2003 08:33:18 UTC