RE: set date using pattern

> -----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,}'/>
	</xsd:restriction>
</xsd:simpleType>

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

pvb

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