Why sum(//*) returns this answer on this xml?

xpath

Solution

Let's break it down:

- the `//*` would match the `a`, `b` and `c` nodes

- the `sum()` function would sum up the results of `number()` function call for every node

- the `number()` function would call `string()` on every matching node

- the result of `number()` for "a" is 23, for "b" is 2, for "c" is 3 - `23+2+3=28`

Problem

This is the xml ``` <a><b>2</b><c>3</c></a> ``` And this is the XPath query ``` sum(//*) ``` Which produces the following result : ``` Type: Num Value : 28.0000 ``` This is XPath 1.0 Please explain the type conversions (step by step)

Original source