Subject: RE: The generic numeric datatype
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 23 Jul 2007 08:34:22 +0100
|
> To maintain the strongest possible typing and semantics when
> defining user functions via xsl:function, what standard
> datatype should be used for 'numeric' in the absence of a
> standard numeric predefined type?
Unfortunately, there's not much you can do. Either define multiple functions
with different names, or use xs:anyAtomicType.
>
> One would not think it to be a significant effort had
> something like xs:numeric or xs:anyNumericType be included in
> the spec.
You'd be surprised. Much smaller things than this have been a significant
effort; you should have listened to the discussion on leap seconds. The
explanation for the problem lies in the history: the fact that the primitive
types were defined by the XML Schema Working group and predated the creation
of a function library to operate on the types.
Another and perhaps more general solution would be allow union types to be
used in a function signature; this would allow the introduction of types
such as xs:numeric without changing the type hierarchy.
Feel free to raise a comment against the specs in a bugzilla entry.
Michael Kay
http://www.saxonica.com/
|