Combining Duplicate Elements in XML Output

Allora offers an option to combine duplicate XML elements when marshalling data to XML. This allows you to organize the XML output to avoid repeating the same super-element for multiple sub-elements. For example, in an XML output file that contains employee and department data, where Employee is a sub-element of Department, you can set the Combine Duplicates property on the Department element so that the Department element is listed only once for all Employee sub-elements in the same department. In effect, you are aggregating all Employee sub-elements with the same Department super-element.

  1. In the Mappings tab, Create mappings between elements and table columns.

  2. In the XML Structure tab, use the list of mapped nodes to identify which elements to aggregate in your XML output file.
    For example, <Item_Detail> elements might be aggregated for each <Orders> element. The Orders elements are combined in the XML output.

  3. In the Combined Node column, click in the row for the element you want to combine. In the example in step 2, you would click in the Orders row.

    The Combine Node Wizard opens to guide you through setting up this node as a combined node.

    Note:
    The Combine and Sort XML Output Nodes in Memory properties are handled internally using a DOM tree. If you use a DOM tree in your application code, for efficiency we recommend that you use XMLRecordset.setDOM to create a DOM when you have set either the Combine or Sort Nodes in Memory properties. If you do not explicitly specify a DOM, Allora automatically creates one and destroys it when the marshalling/unmarshalling operations are complete.

    Note that "Combine Duplicates" is also applied to all ancestors of the element on which you set Combine Duplicates. The Combine Duplicates property inherits up the tree. Attributes cannot be combined.

  1. Perform a test marshal to check your XML output format. If the XML output is not organized as you would like, or you want to optimize marshalling performance, you can customize your settings using the Combine Key, Group and Eliminate Duplicates settings.

See Also

Setting Up Nested XML Elements for Marshalling
Customizing Combine Settings for XML Output

Sample Marshal with Combine Project

XML Structure Tab