From: Ludovic Kuty <mailing@ku...>  20140216 20:23:10

I think I misunderstood the automatic type conversion that happens with the casting of untyped values to the right type to perform the operation. I thought that the xs:untypedAtomic value would be cast to xs:integer to perform the addition but in fact it is cast to xs:double (the rules you mentioned) and I guess the xs:integer is type promoted to xs:double and then we have an addition between xs:double values. Thanks for clarifying the matter. On 16 Feb 2014, at 19:48, Michael Kay <mike@...> wrote: > > On 16 Feb 2014, at 12:04, Ludovic Kuty <mailing@...> wrote: > >> Dear ML users, >> >> I have tried a little example with SaxonEE 9.5.1.4J and thought that the untyped value would be converted to xs:integer instead of xs:double. > > I'm not sure why you expected that. The rules for arithmetic operations in XPath 2.0 are: > > • Atomization is applied to the operand. The result of this operation is called the atomized operand. > • If the atomized operand is an empty sequence, the result of the arithmetic expression is an empty sequence, and the implementation need not evaluate the other operand or apply the operator. However, an implementation may choose to evaluate the other operand in order to determine whether it raises an error. > • If the atomized operand is a sequence of length greater than one, a type error is raised [err:XPTY0004]. > • If the atomized operand is of type xs:untypedAtomic, it is cast to xs:double. If the cast fails, a dynamic error is raised. [err:FORG0001] > > The fourth rule kicks in here, and converts the untyped operand to double. You're then adding integer plus double, which returns a double. > > Michael Kay > Saxonica >  > Android apps run on BlackBerry 10 > Introducing the new BlackBerry 10.2.1 Runtime for Android apps. > Now with support for Jelly Bean, Bluetooth, Mapview and more. > Get your Android app in front of a whole new audience. Start now. > http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk > _______________________________________________ > saxonhelp mailing list archived at http://saxon.markmail.org/ > saxonhelp@... > https://lists.sourceforge.net/lists/listinfo/saxonhelp 