BizTalk Mapping: Compare repeating element values between two part source messages
-
Wednesday, August 15, 2012 6:53 PM
Hi All,
I have two part source messages, and need to compare the "FileNames" element values, if the values in the first schema are not equal in the second one, then route the value to the destination schema. Each source message has thousand of repeating elements. I use "not equal" and "value mapping" funtoids, but it can only compare the first message with only first element value of second message, how can I achieve to compare all of the elements between these two source messages.
Thanks for your help.
Source Schema is:
<InputMessagePart_0>
<getFileName>
<FileNames>
</getFileName>
<InputMessagePart_0><InputMessagePart_1>
<SQLFileName>
<FileNames>
</SQLFileName>
<InputMessagePart_1>And destination schema is:
<FileName>
<FileNames>
</FileName>Source messages are:
<InputMessagePart_0>
<getFileName>
<FileNames>File1</FileNames>
<FileNames>File2</FileNames>
<FileNames>File3</FileNames>
.
.
</getFileName>
<InputMessagePart_0><InputMessagePart_1>
<SQLFileName>
<FileNames>File9</FileNames>
<FileNames>File10</FileNames>
<FileNames>File3</FileNames>
.
.
</SQLFileName>
<InputMessagePart_1>
All Replies
-
Wednesday, August 15, 2012 7:25 PMModerator
You can use the preceding-sibling xslt instruction like in this example
/*/something[not(@result = preceding-sibling::something/@result)]
However this is O(N^2) and will be very slow.
I would create the compound message with all repetitive values and then would use something like XQuery distinct-values to remove the repetitive values. See here.
Leonid Ganeline [BizTalk MVP] BizTalkien: Naming Conventions for the BizTalk Solutions
- Edited by Leonid GanelineMVP, Moderator Wednesday, August 15, 2012 7:27 PM
-
Wednesday, August 15, 2012 7:48 PM
Hi Leonid,
Thanks for your reply. The values of elements in two source messages are distinct-values, how can I use XQuery distinct-values in BizTalk?
For preceding-sibling xslt instruction, yes, you are right, the performace is so poor. Is there other way to deal with this kind of problem? Any shape or ways in Orchestration?
Because in this project, I receive two messages, and need compare all of the fileNames in first message with the filenames in second message, get the filenames not in the second message.
Do you have any ideas to achieve this using BizTalk?
Thanks
R. ZI
-
Wednesday, August 15, 2012 8:17 PMModerator
Create a compound Xml message Create the .NET class to use the XQuery on the Xml string (the example is on the link above). Call this class in the Assign shape. Inside shape it would be something like this:
var_XmlDocument = msg_Compound;
msg_Squezed = Processor.Szueze(var_XmlDocument.OuterXml);Leonid Ganeline [BizTalk MVP] BizTalkien: Naming Conventions for the BizTalk Solutions
- Marked As Answer by LeoTangModerator Wednesday, August 22, 2012 5:28 AM

