It can sometimes be challenging when mapping schemas in BizTalk 2004.  One common problem is when the inbound document has one record and the source creates multiple records based on the data inside your single record.


 


The root problem arises because you have nothing to loop around in the inbound document and need to create multiple nodes on the output.



How can this be handled in the mapper?



Two ways: Functoids or XSLT Template



BizTalk 2004 introduces a new Functoid just for this situation.  It is called the Table Looping Functoid.  It is accompanied by the Table Looping Functoid Data Extractor.  The table looping functoid will take a flat row of data and produce multiple nodes of data on the destination schema.



CRITICAL: The key to working with the table looping functoid is to label your links.  This can be done by selecting the link and going to Properties.  Under General you can set the label.  This will show up inside the Input Parameters section of your functoids as the label name.



An alternative to the Table Looping Functoid is to use a custom XSLT Template call inside a scripting functoid. This requires error prone XSLT coding.



In both cases, the number of input parameters must be known ahead of time.



I have put together a sample showing both the Table Looping Functoid and XSLT Template solutions.



DOWLOAD: Sample Create Nodes in Maps


 


In addition to Node Creation, this sample includes a map called Map_RowSplit.  This sample takes an order item and evaluates the node for “Y” (meaning the item is gift wrapped).  If it is “Y” two line items are created on the output rather then one.  This uses the and XSLT element.