You can use the Union option of the mapper functionality to combine sets of data of the same type into larger sets of data, as shown in the following figure:
Figure : Combining Sets of the Same Data
In this union, repeating elements of the same type are combined into a larger set but in the preceding join example in Example: Merging the Contents of Repeating Elements, the contents of repeating elements are merged.
<xs:choice maxOccurs="unbounded">
This section describes how to create a transformation which combines two sets of repeating elements using the Union option. This section shows how to combine the example XML data shown in the preceding figure.
To Combine Sets of Data of the Same Type
For this example, import the file: PO.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\union directory. The PO.xsd file is used as both the input and output type.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
To select an existing method, in the Design View of the Transformation file:
The elements and attributes that make up the selected element are displayed in the Selected Input Types pane.
For this example, add the PO.xsd/purchase-order element twice.
For this example, expand the PO.xsd schema folder.
For this example, select the PO.xsd/purchase-order element.
The elements and attributes that make up the selected element are displayed in the Selected Output Type pane.
The Design View of the XQ file is displayed.
A dashed line linking the two sub-elements is displayed. The dashed line with long dashes represents a data structural link—a data link that also links two structures. The dashed-line representation for a data structural link is shown in the following figure:
To learn more about the links, see Link Representations.
For this example, link the nodes shown in the following table:
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
To learn more about links, see Link Representations.
For this example, link the $_purchase_orderDoc1/line-items/line-item repeating element in the Source Schema pane to the purchase-order/line-items/line-item repeating element in the Target Schema pane.
At this point, in the Constraint Type pane of the Constraints tab, the Repeatability/Join option is selected.
In the Constraint Type pane, the Union option becomes active because the mapper induces that a union between the first and the second set of repeating elements is possible. A union is possible because the repeating elements contain the same set of sub-elements.
For this example, link the $_purchase_orderDoc2/line-items/line-item repeating element in the Source Schema pane to the purchase-order/line-items/line-item repeating element in the Target Schema pane.
Data structural links between the second set of subelements is generated as shown in the following figure:
<xs:element name="part-no" type="xs:string" minOccurs="0" />
<xs:element name="quantity" type="xs:string" minOccurs="0" />
<xs:element name="part-no" type="xs:string" />
<xs:element name="quantity" type="xs:string" />
For this example, in the Source Data pane, select the $_purchase_orderDoc1 node and import the file: InputPO1.xml. In the Source Data pane, select the $_purchase_orderDoc2 node and import the file: InputPO2.xml. If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\union\XML directory.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
Note: The nodes are being joined in the union and not the data in the nodes. For example, if you are merging repeating elements in which the value of the part-no element is equal to 1, both part-no elements appear in the output as shown in the following figure:
The query returns both repeating elements because it determines the repeating nodes are unique, even if the values of the part-no element are both equal to 1.
![]() |
![]() |