W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > January to March 2002

RE: set date using pattern

From: Biron,Paul V <Paul.V.Biron@kp.org>
Date: Wed, 6 Feb 2002 12:51:15 -0800
Message-Id: <8904C60CACA7D51191BC00805FEAAF4358EA81@crdc-exch-7.crdc.kp.org>
To: "'ching'" <yu_ching@cht.com.tw>, www-xml-schema-comments@w3.org
> -----Original Message-----
> From:	ching [SMTP:yu_ching@cht.com.tw]
> Sent:	Monday, February 04, 2002 11:04 PM
> To:	www-xml-schema-comments@w3.org
> Subject:	set date using pattern
> I want to use xml schema for setting my date datetype.
> I want to get the date is like "19960326".
> How can I set the xml schema that has date element ( is "19960326" not
> "1996-03-26") ?
The only way to do that would be to define your own datatype (by restricting
xsd:string, for instance) and using the pattern facet, e.g.,

<xsd:simpleType name='myDate'>
	<xsd:restriction base='xsd:string'>
		<xsd:pattern value='\d{8,}'/>

However, this new datatype would not be in any way related to the xsd:date


p.s. pattern above allows for arbitrarily large dates (i.e., not limited to
4digit century/year combinations) as does xsd:date...however, it also allows
"20020229" which xsd:date doesn't.  I'm told that it is possible to write a
regex that matches only legal gregorian dates (i.e., gets all the variable
days in a month and leap year stuff right) but I wouldn't want to try to
write it.
Received on Wednesday, 6 February 2002 16:02:25 UTC

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