Oct 052014
 

Here is why the map looks like it does: heavens knows I have gone down this thought process:

‘I want to create a LOC_2 repeating record for each ShipmentStatus element and I also want to create a LOC_2 for every DeliveryCode element. The looping functiod means I want to create a record for whatever is the source, simply linking two of these should work.’

TableMapping1

Unfortunately, the looping funtiod can only be one output, not two looping functiods to the same output.

Here is the input and output definitions:

TableMapping2

Here is some sample data:

TableMapping3

I have created a sample that shows how to solve the problem, one the hard way, the other the easy way.

First the hard way:

Let me explain how you need to think how the out of the box functionality:

"I need to load all of the data into a repeating temporary table and then extract data from the table into the output structure"

Using out of the box functiods:

You want to use the table looping functoid and table extractor functiods

TableMapping4

The arguments to the table looping functiod are:

TableMapping5

The ones that are really​ important are the input[0], input[1],input[4], and input[5], the other ones are hard coded data.

Input[0] is the scoping, generally the root node.

Input[1] is how big the table is going to be (generally the number of output elements you need to create) (we will see the importance in a moment).

Input[4] and Input[5] are the drivers to the creation of the output records.

Now lets look at the table

TableMapping6

I put Data1 and Data2 as the first column (even though it won’t be the first output) and marked the Gated check box, so that if there is no Data1 or Data2 in the input, no empty records be created. For each Data1 record, I am going to create a record and hard code 11, C571data1 and C571data2, for every Data2 I will hard code 12, C571data3 and C571data4 (they could have been links from the source if I wanted)

Now the output:

The link from the table looping functiod is linked to the LOC_2 record (which repeats)

The table extractor functiods are as follows:

  • The top table extractor functiod’s argument is 2 (exctract column 2 (value 11 or 12)

  • The next one under is 1 (column 1’s data)

  • The one after that is 3, and then 4

This returns a result set:

TableMapping7

TADA!

(not easy to understand however)

Now the easy way:

The easy way is to think of it, like I described

"I want to create a structure that needs to be sourced from a repeating structure, and I also need to create the same structure based on a different source element."

So we start by dragging the first ‘source’ to the destination and going into the properties of the other elements and hard coding something

 

and I went into the LOC01 and C5172, and C5173 and hard coded it:

TableMapping8

Now, I validate the map and see the output xsl:

TableMapping9

We want to create a ns0:Output and then we loop through each Data1 and then put data in LOC01 and then map the Data1/text() in the C5171, and put some data in the C5173, pretty easy to understand thus far.​

So let me change the data to match the previous map:

TableMapping10

Now let’s copy the <xsl:for-each node and save it in notepad

Now lets go re-do the map for the second record we want to create

TableMapping11

And looking at the xsl (which looks eerily similar)

TableMapping11

So I change the xsl

TableMapping12

Now I simply copy both of the <xsl:for-each into an inline xsl functiod box and connect the output to the LOC_2 record (no inputs):

TableMapping13

TableMapping15 

Here is what the map looks like:

TableMapping16

I validate it and the underlying xsl looks like this:

TableMapping17

Which also creates:

TableMapping18

Both ways are do-able, I just don’t like thinking that the BizTalk gods at MS put together the functiods. XSL seems more logical to me.

Sorry, the comment form is closed at this time.