Adding a node to the output of a BizTalk map

by eliasen 13. October 2006 21:26


Every now and then, I come across the need of adding a node to the output of a BizTalk map.

Now, if I just want to add some node which isn't dependent on the input, I can just use a custom scripting functoid which is an XSLT template that just craeted the node for me, like this:

Use the "Inline XSLT Call Template" instead, if you need parameters to your XSLT.

BUT, sometimes I need to add a node to a list of existing nodes. One example of this I came across was the need to have a log inside the XML structure that was updated every time BizTalk touched the document. So there would be a structure inside the XML like this:

<LogEntry>This is the first log entry and it was added by Jan</LogEntry>
<LogEntry>This is the second entry and it was added by BizTalk</LogEntry>

So BizTalk needed to add a line to TheLog when BizTalk mapped the document.

Another example is a guy on the microsoft.public.biztalk.general newsgroup that needs to add an OrderItem to an existing list of OrderItems.

To do this, I have only found one solution, which is a custom xslt script that does the whole thing.

My example input schema:

My example output schema:

In both schemas, the "Order"-element can occur multiple times.

The map looks like this:

Basically, just one scripting functoid. Note that no links go from the source document. The scripting functoid is a "Inline XSLT" type, and the source is this:

<xsl:for-each select="//Orders/Order">
<xsl:element name="Order">
<xsl:element name="Ordernumber"><xsl:value-of select="Ordernumber" /></xsl:element>
<xsl:element name="OrderAmount"><xsl:value-of select="Amount" /></xsl:element>

<xsl:element name="Order">
    <xsl:element name="Ordernumber">400</xsl:element>
    <xsl:element name="OrderAmount">40</xsl:element>

Basically, the for-each creates line in the output according to the input XML document. And the xsl:element after the for-each creates the new node.

You can find my BizTalk 2006 project here: (16,89 KB) - it should work with BizTalk 2004 as well.

I hope this has helped someone. Comments are welcome.




BizTalk 2004 | BizTalk 2006

Comments (3) -

Richard Hallgren
Richard Hallgren
12/12/2006 7:27:19 AM #

I ended up reading this post when looking for a solution to add a XML comment on the top of a output message. Even if your post didn't solve my problem I thought I'd post our solution for future readers having the same problem.

How to add a XML comment (or process instruction) on top of the output XML message:


1/19/2007 3:12:06 PM #


I have the same situation that is on my destination scheema there is a node that contains catalog schema but the node is so big that it doesn't fit in inline xslt script functoid can you tell me how should i do it so that it gets added on destination side otherwise I need to create an xslt and link that in biztalk mapper using custom xslt path that is something I need tio avoid.

Any help is appreciated



Jan Eliasen
Jan Eliasen
1/19/2007 10:01:46 PM #


I am not sure what you mean? I have just added a node to my destination XML with a name that is 165 characters long. What do you mean by "the node is so big that it doesn't fit in the inline xslt script"?



Add comment

  Country flag

  • Comment
  • Preview

About the author

Jan Eliasen is 37 years old, divorced and has 2 sons, Andreas (July 2004) and Emil (July 2006).

Jan has a masters degree in computer science and is currently employed at Logica Denmark as an IT architect.

Jan is a 6 times Microsoft MVP in BizTalk Server (not currently an MVP) and proud co-author of the BizTalk 2010 Unleashed book.

BizTalk Server 2010 Unleashed

Buy from Amazon

Microsoft MVP

6 times: July 2004, July 2008, July 2009, July 2010, July 2011, and July 2012. Not currently an MVP.


Image to show

Month List

Page List