I don't know if this will help you, but I have a similar situation in which I have an element that has a repeating child element called "time". I want the total of the times to appear at the beginning of the element. I did this using Styler by setting up generated text on the element with the XPath expression "sum(.//time)". This puts the sum of all the child "time" elements at the beginning of the element as generated text.
The total exists only as generated text, not as a value in the XML file. So whether this solution works for you depends on whether you're okay with having the result exist only as generated text. Also, I don't know whether you're using Styler, but I assume you can do the same thing with FOSI.
I hope that helps.