W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2002

Re: date

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 30 Aug 2002 11:03:30 +0100
Message-ID: <231542814660.20020830110330@jenitennison.com>
To: Mgr Georg Black <georg.black@seznam.cz>
CC: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>

Hi Georg,

> I am trying xerces 2.0.0.(after 1,3,1). With 1.3.1 I used atribute
> with type date in format dd.mm.yyyy with optional one or two digits
> "dd" and "mm". But now I read, that in new version is type date in
> format yyyy-mm-dd and required two digits on position "dd" and "mm".
> I need accept xml files with the same format everything! How can I
> set the format of date?

The only dates that W3C XML Schema recognises are those that follow
the ISO 8601 format of YYYY-MM-DD. It doesn't think that "30-Aug-02" is
a date, nor "30.8.2002", just as it doesn't think that "minus one" is
an integer or "3 weeks" a duration.

To allow an element or attribute to take both an xs:date (YYYY-MM-DD
format) and a token in the format d.m.yyyy, you need to create a
simple type that unions together the two formats. The latter format
needs to be created by restricting xs:token using a regular
expression. Something like:

<xs:simpleType name="myDate">
  <xs:union memberTypes="xs:date">
      <xs:restriction base="xs:token">
        <xs:pattern value="[0-3]?[0-9].[0-1]?[0-9].[0-9]{4}" />

Note that the above pattern doesn't do any checking to see whether
the token-in-the-format-d.m.yyyy actually represents a valid date --
the value 29.2.2002 will count as valid even though this year wasn't a
leap year, for example.



Jeni Tennison
Received on Friday, 30 August 2002 06:03:31 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:58 UTC