I was browsing trough the available answers, but couldn't find one that I understand nor could apply to my case, so I'll try it with this question.
I have a Document that is build up like this
/
<quantity>5900</quantity>
<paper_detail_summary>
<pd_sheets_std>9853</pd_sheets_std>
</paper_detail_summary>
<route_detail>
<no_up>1<no_up>
</route_detail>
<route_detail>
<no_up>2<no_up>
</route_detail>
The sum is "paper_detail_summary/pd_sheets_std - (quantity div route_detail/no_up)" where the (quantity div route_detail/no_up) must apply for each occurrence of a route_detail and be substracted from what's left of paper_detail_summary/pd_sheets_std
9853 - (5900 div 1) = 3953
3953 - (5900 div 2) = 1003
Thus resulting in the desired value of 1003
Note that the no_up is not an auto increasing value, it could have been 2 and 4 for example, it's the number of products per sheet.
Many thanks in advance.