Geeks With Blogs
SOA & Integration Services - BizTalk, WCF, WF, AppFabric etc Why is it drug addicts and computer afficionados are both called users?

This is a simple explanation of how to join together two schemas with a 1:1 relationship between them in the Biztalk Mapper. I came across this problem when I had 2 legacy csv files which needed to be merged (using a unique identifier field in each file) before further processing could occur in a Biztalk Orchestration.

I will show by example. The example is a bit convoluted, but stay with me ;) different departments are ordering the same parts but are paying different prices we want to see the difference in price for the parts. There are also fields missing from each field which we want to add to the finished schema.

1) So first create 2 schemas one for each department, note the common PartID which is the unique identifier and price, but also not that one file comes with a Part name and another with a manufacturer:


2) Create the Output Schema

3) Now create an orchestration which will call the Map to join the two schemas by taking them both in and using a transform shape to map the two then it will output them

4) Set the transform properties as below create a new map set the destination to the output map

5) Which will create a map

6) Finally the biz … ok on the map join the common fields from the first schema (but not the second) with fields in the output schema now add a script functoid and set it up like this. Using an XSLT template it will search the second message for the values (simple xpath) where the PartID in the first message matches the PartID in the second message. It will then return the value of the price attribute in the second message. From this you can see how powerful using inline xslt is.

7) Add another script block to get the manufacturer field set the inline script buffer to:

 

 

9) Join up the schemas in the final map like so … THE END!

R. Addis

Posted on Friday, April 22, 2005 5:55 AM BizTalk | Back to top


Comments on this post: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hi! I found your article on doing selects on another message using xslt call templates located at this url:
http://geekswithblogs.net/synboogaloo/archive/2005/04/22/37335.aspx

The article was well written and worded but I couldn't get it to work.
:-/ If you could take a few minutes and help me out I'd sure appriciate it. I would be able to provide screenshots, xslt, and/or anything that would be helpful.

Thank you again for your time!
-Craig
Left by Craig on Feb 23, 2006 4:02 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hi Craig,
Send me the screen shots I can tell you when I'll be able to do it but hopefully soon.
Cheers
Rob
Left by Rob A on Feb 23, 2006 4:03 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
First glimpse nothing is glaringly wrong although I suggest you try the following
1) Check your test input xml on both message parts that they contain the correct values for the Cuspid and BaseInterestDate
2) Try a more explicit xpath i.e.
//NFSAccruedIncomeSecurityMaster/Securities/Security[..]/..
3) RECOMMENDED: I don't often use the BizTalk mapper for transformations anymore because:
1) You can't put comments in it
2) It generates poor xslt which doesn't perform well
3) It is a real pain to debug you can't step through it
4) It is hard for a developer to read, one has to point and
click lots functoids to see methods parameters etc the code isn't
all in front of them.
Instead I write external XSLTs. Buy an XSLT debugger i.e. XMLSpy or Oxygen (much cheaper) and write your maps in a (pure) xslt style sheet.
You can make calls to BizTalk Functoids and your own C# assemblies in the style sheet by modifying the ExtensionObjects.xml file to reference those classes which maps the assemblies to a namespace in your style sheet. Yes it'll take a while to get the hang of this.
Let me know how it goes.
Left by Rob A on Feb 23, 2006 4:04 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Thanks for the great input. I have started looking at building my own xslt document like you suggested. Do you have any good resources I can refer to for your not using BizTalk mapper for transformations but still allowing an orchestration to use one that I built manually? (I apologize for asking this question but I am really new to BizTalk development).

Also do you think you can send me the generated xslt document that was generated for your example? I would really like to take a closer look at a few things.

Thanks a ton Rob you have already been a great help!

-Craig
Left by Rob A on Feb 23, 2006 4:05 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hey Craig,
I don't have a lot of spare time at the moment but there's loads of examples out there google: biztalk maps external xslt I would take the following approach if you are going to include calls to assemblies i.e. functoids in your external xslt:
Comment them out in your xslt, and then debug through the external xslt in your xslt debugger. Then add the function calls to the xslt and assemblies to the ExtensionObjects.xml set the properties on the btm file to point to the ExtensionObjects.xml and xslt files and debug them in BizTalk (looking at outputs). You can achieve debugging through xslts with calls to external assemblies using xmlspy however it is difficult you need to use a different xslt transformation engine but for now you will be able to achieve what you want using the method I've described above.
Cheers
Rob
Left by Rob A on Feb 23, 2006 4:06 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hi Rob,

I just wanted to let you know that I figured out my problem actually a few hours after you replied. It turns out that I needed to use an xpath query that looked like <xsl:value-of select="//*[local-name()='SecurityMaster']/*[local-name()='Securities']/
*[local-name()='Security' and @Cusip=$Cusip]/@DebtInterestRate" />

Weird that I couldn't have used just the name values by themselves in the select.

Anyway I just wanted to pass the word on. Thanks for your help!

Regards,
-Craig
Left by Craig on Mar 01, 2006 7:02 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
I think only the first receive should be set to activate = true, not both. Look at using a parallel actions shape if you're not sure which message will arrive first but want both messages to arrive before you continue. The orchestration I have shown above is sequential.
Left by Rob A on Jul 27, 2006 6:38 PM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hi
Thanks alot for publishing such blogs.
Right now i m getting a simple problem.
1. I want to test schema and Map for that i need to use Input xml and Output xml in Map Item.Bt problem is that ther is 2 input so how can i test both.


2. second prob is that in orchestration you r using 2 Receive shape among which one should be set activate property as TRUE and either other should be correlated. I just wanted to know u r using correlation or something else.
Please help me


Thanks
Ashwini
Left by Ashwini on Jun 28, 2007 12:19 AM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Answer to first question is easy here: http://www.blogbiztalk.com/?p=55 answer to second question is yes I'm using corrolation it's a sequential convoy
Left by Rob on Jun 28, 2007 1:07 AM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Thanks a lot Rob,

But still i m getting a problem with sequential convoy.
I hv created 3 message:2 for 2 input schema and 1 for output
for that i hv created 3 ports respectively.
But after compilation i m getting error that same port shoul be used.
please help me.

Shoul i use same port type but how that message for schema2 can be identified by orchestration.

Let me be clear that i m using port type as specify now and created to recv location and 1 output folder.
it may be silly to ask bt i m not clear here that should i use any self correlation concept for port .
if yes then for which one port.
next, which one receive shape should be intialised and which one should be folled. Is first Recv shape should be initialised the actiavte=True or False.

Or i m missing anywher else.


Last request, i just want to explore more in XSLT , if u hv published more blogs or any link then pls send me.

lots of thanks
realy ur blogs made me to learn XSLT ..

Left by Ashwini on Jun 28, 2007 1:57 AM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Use 3 ports initialse the correlation set on the first receive and make the correlation set following on the second receive. I don't think you should be self correlating. You need to create a correlation set which consistes of a promoted field that is a unique value or values in both your input files in my example above it would have been PartId.

As for xslt resources I use this a lot http://www.zvon.org/xxl/XSLTreference/Output/index.html also there are some good reference books out there. Also the BizTalk sdks will show you how to get external XSLTs to work with the BizTalk mapper.
Left by Rob on Jun 28, 2007 4:06 AM

# re: Implementation of Message Transformation Normaliser Pattern in the BizTalk 2004
Requesting Gravatar...
Hi,

very nice post, but please put more effort to explain in details. it will be help full for new guys


thanks,
Left by Genious on Aug 16, 2007 10:51 PM

Your comment:
 (will show your gravatar)


Copyright © Rob Addis | Powered by: GeeksWithBlogs.net