RE: F&O avg and sum should automatically cast anySimpleType to n umeric

John Mercado: 
> 
> >From the way I read the descriptions of the avg and
> sum functions, you can't use them if the values in the
> sequence aren't explicitly typed as numbers.  For
> example, if my instance is:
> 
> <root>
>   <num>12</num>
>   <num>15</num>
> </root>
> 
> I can't say sum(//num) unless I have a schema that
> declares that num has a numeric type.  
> 
> This seems like a major inconvenience and an
> incompatibility with XPath 1.0.  I hope I'm missing
> something.
> 
> Of course, it may be that when the spec says "If,
> after this, $srcval contains only numbers..." it means 
> "contains only atomic values with numeric types _or_ 
> anySimpleType values that can be cast to numeric types." Is 
> that the part I'm missing?
> 

I'm sure it wasn't anyone's intent to stop sum() working with untyped data,
and you are right, the spec is very unclear on this point.

Michael Kay

Received on Tuesday, 8 October 2002 07:33:49 UTC