Enclosing Context
The Enclosing context is used by loop expressions associated with aggregate functions (those functions starting with "Ag"). Normally this type of looping is done within the current output map element's looping. For example, if you have a loop in the output for an invoice, and you want to calculate the total of all of the line items, you use the AgSum function and simply specify a loop on the line items. It will automatically assume you want only line items from the enclosing invoice. However, if you want to include line items from other invoices, use the enclosing context to specify a loop higher than the invoice (the root output element in this case), and then the AgSum function will look at all line items of all invoices.