Here is an example of using the Transform builder to map from one schema to another.
Let's assume a source schema like this:
<person>
<name>
<last_name>Smith</last_name>
<first_name>John</first_name>
</name>
<address>
<street>222 Main St.</street>
<city>Indianapolis</city>
<state>IN</state>
<zip>46022</zip>
</address>
<junk>My name is John Smith.</junk>
</person>
</person_list>
And a target schema like this:
<person>
<last_name>string</last_name>
<first_name>string</first_name>
<street>string</street>
<city>string</city>
<state>string</state>
<zip>string</zip>
<description>string</description>
</person>
</person_list>
Since the source schema has multiple container nodes in it, you must apply multiple Transform builders to achieve the desired effect. I've used 3 Transform builders here each applied in sequence using an Action List.
The first Transform builder points to person_list/person/name in the source and copies this to person_list/person in the target. The important point here is that there are 3 levels in the source schema and 2 levels in the target schema. So, in the Parent Node mapping section, you must map the top level nodes to each other, then skip the intermediate level nodes in the source schema, and finally map the lowest level nodes to each other.
The second Transform builder points to person_list/person/address in the source and copies this to person_list/person in the target. This one is even trickier. Again, there is a difference in number of levels in the source and target schema. So, the same Parent Node mappings must be used here. In this case, however, on the lowest Parent Node mapping (address->person), you need to match nodes based on Child Node Text. The Source To Match input needs to navigate from person_list/person/address to person_list/person/name/last_name, so I've manually typed the XPath ../name/last_name here to achieve this. (This cannot be done through the picker.) The Target To Match input needs to navigate from person_list/person to person_list/person/last_name. The picker was used to choose this XPath (person/last_name). This will instruct the transform to match nodes based on the last_name field, which should already be copied from source to target using the first Transform builder described above. (This would not be an appropriate primary key to use if you have multiple people in the list with the same last name. You should consider augmenting the schema with an additional field that can be used as a unique key for the Transformation.)
The third Transform builder points to person_list/person in the source and copies this to person_list/person in the target. This builder has an equal number of parent nodes in both schemas, so the default Parent Node mapping is ok. However, we still need to make sure that the person node is matched appropriately.& nbsp; So, for the person node in the Parent Node mappings, we choose Source To Match as person/name/last_name and Target To Match as person/last_name. These are the relative XPaths from the person node to the last_name node in each of the source and target schemas respectively. (These can both be picked with the picker.)
The attached model demonstrates this usage of the Transform builder.
TransformTest.model
As an alternative option. The model also demonstrates the use of the Advanced input in the Data Column Modifier builder. The Data Column Modifier builder provides an option to "Flatten Groups Within", which if enabled, will produce output very similar to the three Transform builders described.