- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 25 Sep 2002 10:01:46 +0100
- To: "Saurabh Agarwal" <saurabh.agarwal@staralliance.com>
- Cc: xmlschema-dev@w3.org
Hi Saurabh, > Is it possible to change the format of a dateTime attribute using > patterns? No it isn't. You can't change the way a dateTime value is represented lexically. Similarly, you can't change the way a decimal value is represented lexically -- you can't say that rather than "1000.0" you want to be able to use "1 000,0". > For instance, is it possible to restict the dateTime > (CCYY-MM-DDThh:mm:ss) to just the 'Date' (DD) or "Hours and Minutes" > (hhmm). By 'Date', you mean just the day? You could use xs:gDay, which has the format ---DD (e.g. "---25"), or to get the format DD you could use a restriction of xs:integer that only allowed numbers between 1 and 31 and that fixed the pattern so that exactly two numerals were used: <xs:simpleType name="day"> <xs:restriction base="xs:integer"> <xs:minInclusive value="1" /> <xs:maxInclusive value="31" /> <xs:pattern value="\d{2}" /> </xs:restriction> </xs:simpleType> For hours and minutes, again you could use xs:time (hh:mm:ss) or to get the format hhmm you could restrict xs:integer with a rather weirder pattern: <xs:simpleType name="day"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" /> <xs:maxInclusive value="2359" /> <xs:pattern value="[0-1][0-9][0-5][0-9]" /> <xs:pattern value="2[0-3][0-5][0-9]" /> </xs:restriction> </xs:simpleType> But note that if you don't use types that are derived from the range of date and time types then applications won't recognise them as dates or times. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Wednesday, 25 September 2002 05:09:10 UTC