W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2003

Re: date & time pattern change

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 3 Jan 2003 01:41:22 +0000
Message-ID: <1387595201.20030103014122@jenitennison.com>
To: "Avin Patel" <vze49rz3@verizon.net>
CC: "xmlschema" <xmlschema-dev@w3.org>

Hi Avin,

> "pattern" constraint is applicable on "date"/ "time" type.
> Can any one please provide me sample, how it can be applicable.
> I guess "pattern" restriction on "data"/"time" is confusing. You real can't
> apply pattern restriction on data/time type.

You can use the pattern facet with date/time types to constrain the
kinds of date/times that can be used. For example, the following
simple type will only accept dates that are the first of a month:

<xs:simpleType name="firstOfMonth">
  <xs:restriction base="xs:date">
    <xs:pattern value="\d{4}-\d{2}-01" />

The following simple type will only accept times that are whole or
half hours:

<xs:simpleType name="halfHours">
  <xs:restriction base="xs:time">
    <xs:pattern value="\d{2}:[03]0:00" />

You can't change the lexical space of a type using the pattern facet,
but you can constrain that lexical space to only allow particular



Jeni Tennison
Received on Thursday, 2 January 2003 20:42:04 UTC

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