Friday, 13 October 2006

Hi

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:

<TheLog>
<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>
</TheLog>

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>
</xsl:for-each>

<xsl:element name="Order">
    <xsl:element name="Ordernumber">400</xsl:element>
    <xsl:element name="OrderAmount">40</xsl:element>
</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: AddingANode.zip (16,89 KB) - it should work with BizTalk 2004 as well.

I hope this has helped someone. Comments are welcome.

--

eliasen

Friday, 13 October 2006 23:26:57 (Romance Daylight Time, UTC+02:00)  #    Comments [3]  | 
Tuesday, 12 December 2006 08:27:19 (Romance Standard Time, UTC+01:00)
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:
http://richardhallgren.com/blog/?p=38
Friday, 19 January 2007 16:12:06 (Romance Standard Time, UTC+01:00)
Hi,

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


Thanks
Friday, 19 January 2007 23:01:46 (Romance Standard Time, UTC+01:00)
Hi

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"?

--
eliasen
All comments require the approval of the site owner before being displayed.
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

Theme design by Jelle Druyts