Tuesday, December 20, 2011

BizTalk's Table Looping Functiod in detail

There are several posts based on the Table Looping Functiod:

These are all great examples, but I'd like to get into detail of what may happens when using flatlander's example without using the BizTalk .NET Stew example.

I'm going to copy flatlander's example. My source file looks like this:

Take note that I have 3 Chef nodes, but only 1 MaitreD node.

Testing the map produces the below output:


Notice that I have 3(?!) MaitreD instances of Mr. Cook. That isn't right. My initial suspicions are that you will iterate both the same time as the node which has the highest number of iterations. So if node Chef has 3 iterations (child nodes), you will have the same iterations in your output with your MaitreD nodes.

Not quite what I want.

So, going on, I'm following what BizTalk and .NET Stew explains, by using the gated functionality of the functoid. The question becomes now: How do I gate the input if I only have fewer iterations of one node vs. the other?

Being that the two root nodes in the source are iterative, I can determine which iteration I am on from the source. Taking that one step further, I can also determine if a particular iteration of a node is not null. The assumption is that the node you are comparing cannot be null.

So in this exercise, let's take the Chef/Name and MaitreD/Name as the 'gate' nodes to compare, since I have determined they cannot be null or empty. If a node at a particular index doesn't exist (i.e. Chef/Name[20]), then it will be blank/null. I pipe the 'value' of that index to a NotEqual functoid. I compare it to an empty string, and from there I should have a boolean value which determines if that index of the node exists - my gate.



Let's take a look into the functoid's configurations.
Index:


And NotEqual. The string value is empty (no spaces).


I use these two outputs as column1 of the Table Looping functiod. Also note that I have the Gated checkbox checked, as in BizTalk and .NET Stew explains:


Testing the map, and you have a cleaner representation of the output:


This may not be the most elegant solution, but in this scenario we are using only functiods in the map and staying away from XSLT, scripting, or an external assembly - as many have suggested to do instead.

I personally lean towards the approach that if it's not too difficult, stay within a single pattern or two for supportablity within your development environment.

1 comment:

Anonymous said...

Thanks so much! This has been a scenario that I have been struggling with for a while, and you explained it perfectly.