Subject: Re: [xsl] The generic numeric datatype From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Sun, 22 Jul 2007 23:09:29 -0700 |
The answer then by Dr. Kay was that it is possible (if somewhat subtle) to include such a datatype in a new XML Schema specification.
Since this didn't happen, the only way to cover a set of different numeric data types in a signature of an FXSL function is to specify their most descended supertype -- which in the case of the f:abs() function is item(). The special xs:anyAtomicType was not yet introduced by the w3 WG when the FXSL wrappers around the F & O were written.
Anyway, even specifying this type instead of a xs:numeric type would be too loose, as you rightly notice.
This problem would not have existed (in the majority of cases), if overloading of functions of the same arity was allowed. The problem would still exist for functions with the same arity and types of arguments, that differ only in the types of their return type.
-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play
With reference to XQuery 1.0 and XPath 2.0 Functions and Operators "Functions and Operators on Numerics that accept 'numeric' parameters accept arguments of type xs:integer, xs:decimal, xs:float or xs:double."
'numeric' is an informally defined type within the spec. A typical standard function using this type signature is: fn:abs($arg as numeric?) as numeric?
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?
Since xs:anyAtomicType includes xs:integer, xs:decimal, xs:float and xs:double as well as all the other non-numeric atomic types, it is obviously less specific than 'numeric' and, of course, item() is laxer still. (Saxon apparently understands xdt:_numeric_ as the 'numeric' datatype, but that's not spec-compliant according to my understanding).
As a consequence of there apparently being no standard numeric type, it occurs to me that standard functions such as fn:abs cannot be expressed with 100% transparency via user written functions, as multiple type-wise overloaded versions of these functions (and with the same number of arguments) would result in a duplicate function definition(s).
BTW. The higher-order function wrapper for fn:abs in FXSL uses item() as the type bearer.
One would not think it to be a significant effort had something like xs:numeric or xs:anyNumericType be included in the spec.
Please correct me if I have something wrong.
Cheers
Justin Johansson
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] The generic numeric datatype, Justin Johansson | Thread | RE: [xsl] The generic numeric datat, Michael Kay |
[xsl] The generic numeric datatype, Justin Johansson | Date | RE: [xsl] The generic numeric datat, Michael Kay |
Month |