You haven't shown your source data, which make it difficult to help.

If the numbers are contained as element or attribute values, you can simply do sum(NODESET) where NODESET is an expression that selects the relevant nodes.

If you need to compute the numbers (which includes something as simple as stripping a "$" sign off), it's a bit more complicated. Let's say that EXP($n) is the expression that computes the number for a given node $n.

In XPath 2.0 you can simply do

sum(for $n in NODESET return EXP($n))

In 1.0 you have a choice:

(a) a two pass solution where the first pass creates a tree in which the numbers appear as element or attribute values

(b) a recursive named template

(c) a library routine from EXSLT or FXSL

Michael Kay

http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference