another issue with min/max functions

in XQuery 1.0 and XPath 2.0 Functions and Operators   15.3.2 & 15.3.3,

it seems there is a contradiction in typing rules for functions min & max:
(correct me if I am wrong)

between

"For numeric values, the numeric promotion rules defined in 6.2 Operators on Numeric 
Values are used to promote all values to a single common type."

and

"The value returned by fn:min($srcval) is equivalent to the value returned by the
  following XQuery expression.

       let $ordered-vals :=
         for $val in $srcval
         where $val ne $val
         order by $val
         return $val
       return $ordered-vals[1]
"

If one considers the following expression: max( (2e0 , 2.1) )
the second rule (sort) yields a value (2.1) of type xs:decimal,
while the promotion rules imply a xs:double result type.

The formal semantics don't help much...
BTW the section 6.2.8 puts together
the fn:min fn:max, fn:avg, and fn:sum functions
as if fn:min & fn:max were only numeric functions,
but nothing is said about their other variants.



-- 
Xavier FRANC

Received on Saturday, 11 October 2003 19:57:52 UTC