Saxonica.com

saxon:sum()

sum(node-set-1, stored-expression)

This returns the total resulting from evaluating the supplied stored expression for each node in node-set-1 in turn, as a number. If the result is NaN for any node, the total will be NaN. A stored expression may be obtained as the result of calling the saxon:expression function.

The stored expression is evaluated for each node in node-set-1 in turn, with that node as the context node, with the context position equal to the position of that node in node-set-1, and with the context size equal to the size of node-set-1.

Example: saxon:sum(sale, saxon:expression('@price * @qty')) will evaluate price times quantity for each child <sale> element, and return the total amount.

This function is deprecated, since the same effect can be achieved using standard XPath 2.0 functions and operators, for example, sum(for $s in sale return $s/@price * $s/@qty)

Next