BizTalk: mapping with Xslt

BizTalk Map Editor (Mapper) is a good editor, especially in the last 2010 version of the BizTalk. But sometimes it still cannot do the tasks easily. It is time for the Xslt code, it is time to remember that the maps are executed by the Xslt engine. 

Right-click the Mapper Grid (a field between the source and target schemas) and choose Properties /Custom XSLT Path.  Input here a file name for the file with Xslt code. Only this code will be executed now, forget the picture in the Mapper, all those links and functoids. 

Let’s see the real-life example. It is the typical example of the "schema flattening". We have a target record and we have to create it from different unrelated source records.

As we can see, there are two source Addresses. One is on the top level and the second one is inside the Member_Address record with MaxOccurs=* .

A target address is placed inside the Locator record with MaxOccurs=*.


The requirement is to map all source addresses to one target address.

The source Xml document looks like:


The result Xml should be like this:


Try to make up this mapping with the Mapper and you would spent good amount of time and the result map would be tricky.

If we use the Xslt code, the mapping will be simple and unambiguous, like this:


There are two identical pieces creating the Locator records. 

The first one is started with <xsl: if test="s2:Address_1". It maps the upper level address to the Locator.

The second one is started with <xsl: for-each select="s2:Member_Address/s2:Member_Address". It also maps the addresses nested inside the /../Member_Address/Member_Address record to the Locator.

Simple, clear.

Print | posted on Thursday, June 14, 2012 11:55 PM


# re: BizTalk: mapping with Xslt

left by kevin at 7/26/2013 5:05 PM Gravatar
hi what is the 's2' in the 'test' expression?
Post A Comment