This is easy in XPath 2.0:
It can't be done in pure XPath 1.0 because the argument to sum() has to be a set of nodes; your nodes don't contain numbers, and XPath alone can't create new nodes. You can do it in XSLT 1.0 - one way is to write a recursive template that processes the nodes one by one, adding to a running total as it goes; another way is a two-pass approach where you construct a new tree containing the translated nodes. But 2.0 is much easier.
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference