Tuesday, September 13, 2011

BizTalk Inline XSLT Call Template and Namespaces

If you have used the Inline XSLT Call Template at all, you will notice at times that your map will validate just fine, but the output may not be exactly what you want (sometimes just an empty single node).

A little gotcha is that you need to be aware of the namespaces within your schemas, or the output of your map will be less than desirable.

Let's take a simple scenario. I'm mapping one source schema to a single destination schema.



In this example, I'm trying to iterate through a node and essentially pass the input parameter through:



Unfortunately my output looks a little small:



Interesting. Not a single error, but not what I was expecting.

The problem here is that with my XSLT code, I overlooked the namespace of my source schema. To get the proper namespace, I save the latest version of my map, validate it,



...and then take a look at the output XSL file. The location of this file is displayed in the output window.



Within the .xsl file, I will now be able to get the proper namespace of my schema,



In this case, the namespace is s0, as in s{zero}. Now I can apply this to my XSTL Call functoid.



A subtle difference, with drastic results:

2 comments:

SAI said...

This is very risky. Try re-deploying the source schema and see what happens. BizTalk will create new namespaces and s0 might be s1 now.

So I'd advice you to define the namespace and its prefix yourself in your own script. That way you're script will keep on working as long as the namespaces don't change

Tank said...

SAI,

The intention of the post was to help others understand what is going on, why it's happening, and how to get 'expected' results when testing within Visual Studio.

How you 'harden' this is completely up to you.