Thoughts on Systems Integration using Microsoft Technologies

Using Inline XSLT to Populate an <Any> Element

I have been working recently with schemas containing <Any> elements.  Luckily I don’t need to manipulate the <Any> contents much: to do so, the standard BizTalk functoids available in the mapper can’t be used and instead, given the range of the XML that can be expected in the <Any>, some extensive custom XSLT would be required.

I have two scenarios:

  1. The contents of an <Any> element need to be copied to a known schema “as is”.
  2. The contents of a known schema need to mapped “as is” to an <Any>.

I struggled with the mass copy functoid for both scenarios – it didn’t behave quite how I expected/wanted.

After a bit of head scratching and a read of this blog post, I realised that the mass copy doesn’t copy across root elements.  I suppose, for example, the assumption is that both source and target schemas will contain a common element that can be used as the “target” of the mass copy functoid.  This wouldn’t work in my case, since the schemas being mapped are quite different and also the <Any> would contain a range of different XML, so I couldn’t specify an appropriate containing “root” element.

To get around this behaviour of the mass copy functoid, in my map I created a scripting functoid and added some inline XSLT like this:

<xsl:copy-of select=”.” />

My map then looked like this:

Map With "Mass Copy" in Inline XSLT

Map With “Mass Copy” in Inline XSLT

Here is an example instance of the source message:

Source Message

Source Message

And this is the result after passing the message above through the map:

Output Message

Output Message

Also here is the output message if the mass copy functoid is used (note that the root <Order> element is missing, under <Entities>):

Output Message Using Mass Copy Functoid

Output Message Using Mass Copy Functoid

It seems strange and limiting that the mass copy functoid doesn’t copy the root element.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s