Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] The generic numeric datatype

From: "Dimitre Novatchev" <dnovatchev@--------->
To:
Date: 7/23/2007 6:10:00 AM
AFAIR, I raised this problem two years ago in this list.



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


On 7/22/07, Justin Johansson <procode@xxxxxxxxxx> wrote:
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent