xsl-list
[Top] [All Lists]

RE: format-date and xsd:date

2004-08-10 00:43:15
XML Schema offers additional data types such as gYear and gYearMonth which
appear to be what you are looking for; however, there is very little direct
support for them in XPath functions and operators. Frankly, I think that the
proportion of the schema type system and the XPath function library given
over to handling of the calendar is already quite disproportionate.

If you do want to use the gYearMonth data type, you can write your own
function f:format-gYearMonth which converts the value to a date:

xs:date(concat($gYM, '-00'))

and then applies format-date() to it.

Michael Kay



-----Original Message-----
From: Bruce D'Arcus [mailto:bdarcus(_at_)myrealbox(_dot_)com] 
Sent: 10 August 2004 02:52
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] format-date and xsd:date

I'm not really sure where this question/comment ought to go, 
but since 
it came in the midst of working with XSTL 2, this seems a good place.

The data-typing-related support in XSLT 2 is based on XML 
Schema.  So, 
in both cases, a "date" is defined as YYYY-MM-DD, and 
anything else is 
invalid.  While this makes sense when you consider YYYY/MM/DD, 
MM-DD-YYYY and so forth, why can't all of the following be 
valid dates?

YYYY-MM-DD
YYYY-MM
YYYY

This comes out of working with bibliographic data, where one 
typically 
has issue dates of year-only, sometimes year-and-month, and only 
occasionally the full "date" as understood by xs:date.

This means I have to define my own schema patterns if I write 
a schema, 
and my own equivalents to handle the stuff in XSLT 2 if I 
don't want to 
select the substrings.

Does nobody else find this a problem?  Is there any prospect 
to change 
it?

I'm just having a hard time understanding how I can code a schema to 
enforce dates of the sort I deal with and also get the 
advantage of the 
datatyping and XSLT 2 date formatting.

If I do:

<date year="1999" month="03"/>

... that's easy to control and flexible, but there's no format-month 
function (in Saxon 8 at least).

Bruce


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>