Re: date & time pattern change

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" />
  </xs:restriction>
</xs:simpleType>

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" />
  </xs:restriction>
</xs:simpleType>

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
values.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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