Duplicating Subtrees 
You use this procedure to duplicate subtree in the target structure in order to assign source fields to multiple positions of an element in the target structure.
Even if elements shown occur more than once in the XML instance, according to the XML Schema definition, they are only displayed once in the structure overview. Hence to assign source fields to multiple positions of an element in the target structure, you need to either copy individual elements or the entire subtree using the context menu in the target structure.
Choose the node on the target structure to duplicate the individual element or the entire subtree.
Right-click to get the context menu and select Duplicate Subtree.
Note
The duplicate gets created and can be identified with a + symbol on its image. The paths of the duplicate nodes are suffixed with [i] where “i “ starts with 1.
If you want to delete a duplicate subtree, right-click on the duplicate node in the target structure and select Delete Subtree from the context menu.
Below example describes the need of duplicating a subtree and how message mapping is done with duplicated elements.
Example
The records of a CD catalog are to be mapped to a simple HTML table. There are six subelements of <cd> in the source structure that are to be shown in one table line. However, the target field <td> is only shown once in the structure view.
Source Structure |
Target Structure |
||||
Field Name |
minOccurs |
maxOccurs |
Field Name |
minOccurs |
maxOccurs |
Catalog |
1 |
1 |
CatalogTable |
1 |
1 |
cd |
0 |
unbounded |
table |
1 |
1 |
title |
1 |
1 |
tr |
0 |
unbounded |
artist |
1 |
1 |
td |
0 |
unbounded |
country |
1 |
1 |
|||
company |
1 |
1 |
|||
price |
1 |
1 |
|||
year |
1 |
1 |
|||
Before you can define the target field mapping to the <td> elements, you must first duplicate the <td> element five times using the context menu. Each target field mapping then comprises simply a 1:1 assignment of the source and target fields:
Message Mapping with Duplicated Elements
Target Field Mapping |
/CatalogTable=/Catalog |
No mapping for/CatalogTable/table |
/CatalogTable/table/tr=/Catalog/cd |
/CatalogTable/table/tr/td=/Catalog/cd/title |
/CatalogTable/table/tr/td[1]=/Catalog/cd/artist |
/CatalogTable/table/tr/td[2]=/Catalog/cd/country |
/CatalogTable/table/tr/td[3]=/Catalog/cd/company |
/CatalogTable/table/tr/td[4]=/Catalog/cd/price |
/CatalogTable/table/tr/td[5]=/Catalog/cd/year |
Source Instance |
Source Instance Result |
<?xml version="1.0" encoding="UTF-8"?> <Catalog> <cd> <title>Empire Burlesque </title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90 </price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>91.90 </price> <year>1988</year> </cd> </catalog> |
<?xml version="1.0" encoding="UTF-8"?> <ns0:CatalogTable xmlns:ns0="workshopDemo"> <table> <tr> <td>Empire Burlesque </td> <td>Bob Dylan</td> <td>USA</td> <td>Columbia</td> <td>10.90 </td> <td>1985</td> </tr> <tr> <td>Hide your heart</td> <td>Bonie Tyler</td> <td>UK</td> <td>CBS Records</td> <td>91.90 </td> <td>1988</td> </tr> </table> </ns0:CatalogTable> |