Some XSLT for when you just can’t get the mapper to do what you want it to do
Update - Please see my subequent post titled “Finding out the mapper can do what I want it to do” which makes this “hack” not necessary any longer
Recently I have been spending some (maybe too much) time on the msdn forums to see if I can help out anyone that is having a problem with BizTalk. I figure since most of my knowledge comes from reading blog posts, I need to do something that gives back to the world.
So on friday a post showed up about needing to map from one format with data in a non repeating header and moving it to a repeating element in a destination document. You can read actual post here. An example of the source and destination would be as follows
The source schema looks like:
And our destination schema looks like
So as you can see we need to take the PONum and ShippingDate attributes from the Header element of the source document and put them into two different MainLoop elements in our destination document. Then take the repeating Item elements from the source and fill out the remaining MainLoop elements in the destination document.
Getting the PONum and ShippingDate out proved to be a bit more challenging than I had orignally thought. I did not want to write just straight XSLT and by pass the mapper. That is always an option, but then I am not really using the tools available. What I decided to do was use inline XSLT in a scripting functoid to copy the Source\Header\PONum and ShippingDate fields to the MainLoop. So I came up first with a map that looked like this
But the Xml was not what I wanted… (not even close!)
So when looking at the xslt the map was creating I realized that getting a MainLoop element for both my PONum and ShippingDate field would require me to have an “empty” spot in my destination schema that I could push the XSLT from my two scripting functoids into. So I created a temporary destination schema that contained a “PlaceHolder” for me to overwrite.
Now my map looks like this…
Which produces the correct output…
Now I know, if this is a huge document, or I am doing lots of these throughout the day and performance is a very big consideration the straight XSLT approach would be more performant, but until I need to have the speed, I will take the maintainability. You can download the project that demonstrates this here
Mape1082 I hope this helps you somehow.
1 Comment »
Leave a comment
-
Recent
- What I Learned Yesterday 12
- What I Learned Yesterday 11
- What I Learned Yesterday 10
- What I Learned Yesterday 9
- Energy Options for the US
- What I Learned Yesterday 8
- What I Learned Yesterday 7
- What I Learned Yesterday 6
- Finding out the mapper can do what I want it to do
- Some XSLT for when you just can’t get the mapper to do what you want it to do
- What I learned yesterday 5
- What I Learned Yesterday 4
-
Links
-
Archives
- May 2008 (2)
- April 2008 (2)
- March 2008 (3)
- February 2008 (3)
- January 2008 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS






[...] Ben Runchey’s Integration Dev Blog a.k.a Ben’s spot to put stuff he does not want to forget « Some XSLT for when you just can’t get the mapper to do what you want it to do [...]
Pingback by Finding out the mapper can do what I want it to do « Ben Runchey’s Integration Dev Blog | February 19, 2008