[xsl] User-defined datatypes in XSLT 2.0 (Was: Re: [xsl] regexs, grouping (?) and XSLT2?)

Subject: [xsl] User-defined datatypes in XSLT 2.0 (Was: Re: [xsl] regexs, grouping (?) and XSLT2?)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Aug 2004 16:59:48 +0100
Hi Mike,

> I think it is worthwhile treating your "union of YYYY-MM-DD,
> YYYY-MM, or YYYY" as a user-defined data type (say m:date), and
> defining your own function library to manipulate this type. For
> example, you can define functions like m:get-year($p as m:date) to
> extract the year, m:make-date($s as xs:string) to construct an
> instance of this type, m:compare() to compare two instances, and so
> on.

Right: interestingly, this is precisely the approach that I'm taking
when incorporating datatypes created with the datatype library
language (old version at http://www.jenitennison.com/datatypes; new
version coming soon) into XSLT 2.0. The values of these user-defined
datatypes, which get passed around between functions, are actually
elements with a string value and a type annotation and various other
things. I have a dt:compare() function that does datatype-aware
comparisons and dt:eq(), dt:lt() etc. functions that call it and have
to be used instead of the 'eq', 'lt' etc. operators. It's all pretty
horrible, and I haven't even thought about how to do datatype-aware

Another approach would be to create a Java class that represents the
datatype and somehow hook this into Saxon; I'm not sure that it's all
that easy, however. Any pointers, Mike?



Jeni Tennison

Current Thread