A disciple of Domain Driven Design (DDD), Microservices and Event Driven Architectures

Here’s a cool mapping tip I found on Vijendra’s blog.

While mapping an element from the source schema to the target schema, it is possible to copy either the value contained within the element or the element name itself.

You achieve this by setting the Source Links property of the link connecting the elements as shown below.

In the above figure above the value mapped to the target element will be “CustomerName”.

The values that can be set are:
1. Copy text value – which is the default that copies the content of the element
2. Copy name – copies the name of the source node instead of its value
3. Copy text and subcontent value – concatenates the value of all child nodes

Now you might be wondering what is this 3rd value (Copy text and subcontent value) that can be set…

This is used if you want to concatenate all the child element values of the source node into a single element in the target as shown below.

Here is an example:

Input Message
<ns0:Root xmlns:ns0=”http://MapTest.SourceSchema“>
<Record>
<FirstName>FirstName_0</FirstName>
<LastName>LastName_0</LastName>
<Street>Street_0</Street>
<City>City_0</City>
</Record>
<Record>
<FirstName>FirstName_1</FirstName>
<LastName>LastName_1</LastName>
<Street>Street_1</Street>
<City>City_1</City>
</Record>
</ns0:Root>

Output Message
<ns0:Root xmlns:ns0=”http://MapTest.DestinationSchema“>
<Record>
<Data>FirstName_0LastName_0Street_0City_0</Data>
</Record>
<Record>
<Data>FirstName_1LastName_1Street_1City_1</Data>
</Record>
</ns0:Root>

Now here is another interesting mapping

The mapping above transforms the elements in the source schema into a key-value pair as shown below.

Each element node from the source schema links to the two elements in the target schema, one link copies the node name and the other copies the node value.

Input Message
<ns0:Root xmlns:ns0=”http://MapTest.SourceSchema“>
<Record>
<FirstName>FirstName_0</FirstName>
<LastName>LastName_0</LastName>
<Street>Street_0</Street>
<City>City_0</City>
</Record>
</ns0:Root>

Output Message
<ns0:Root xmlns:ns0=”http://MapTest.KeyValuePair“>
<Record>
<FieldName>FirstName</FieldName>
<FieldValue>FirstName_0</FieldValue>
</Record>
<Record>
<FieldName>LastName</FieldName>
<FieldValue>LastName_0</FieldValue>
</Record>
<Record>
<FieldName>Street</FieldName>
<FieldValue>Street_0</FieldValue>
</Record>
<Record>
<FieldName>City</FieldName>
<FieldValue>City_0</FieldValue>
</Record>
</ns0:Root>

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: