How to add subtotals on rtf template



I have some knowledge on BI Publisher, but i don't how to add the subtotal values from XML into RTF template.

I created a UBE to print the item details and print subtotals of quantity on hand.

I have uploaded the xml file to rtf template and inserted detail fields to the template .But i don't know how to add the sub total xml tag to the template.

pls let me know how to add the subtotals in rtf template.

let me know for additional details.