Re: formatting date and time fields

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 UTC