W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: formatting date and time fields

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 23 Feb 2002 23:49:48 +0000
Message-ID: <4726820165.20020223234948@jenitennison.com>
To: Kiran Edukulla <kiran@nightfire.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Kiran,

> I have a question about date and time formatting in schemas. I need
> to output a date field as "MM-DD-CCYY" and time field as
> HHMM(AM/PM).

When you say 'output', what do you mean? Do you mean that the XML that
is described by the schema has to contain dates and times in the
formats that you specify, or do you mean that what the end-user sees
in the application have to be in the format that you've specified?

If the XML that you're creating, and that will be validated by your
schema, needs to use those formats, then you can't use the xs:date and
xs:time data types. The XML Schema data types have a fixed, standard
syntax, and to a schema validator, any date that isn't in the format
CCYY-MM-DD isn't a date at all. Instead, you have to create your own
data type, probably derived from xs:token, with a pattern facet to
test the format.

If you're creating some output from the XML validated by the schema,
then you should use a transformation technology, such as XSLT or
XQuery or something written in your favourite programming language, to
format the date and time in the way that you desire. Without knowing
what transformation technology you're using, I can't tell you how to
do that, and probably you should take the question to a list about
that transformation technology rather than ask it here.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Sunday, 24 February 2002 04:36:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:27 GMT