Search code examples
xsltbiztalkbiztalk-2010biztalk-2013biztalk-mapper

BizTalk mapping: how to extract single row from looping


I have the following issue. In BizTalk core (XML) I have a tag which may be replicated few times. It's cardinality is n, let's say - in theory 0 ≤ n ≤ 99. Let's call it Note[n].

In outgoing file (it's flat) I have five (exactly five) appropriate fields. Let's call them FTX1..5. So what I need to do is to map Note[1] (if it exists) to FTX1, Note[2] (if it exists) to FTX2, ..., Note[5] (if it exists) to FTX5.

Is it possible to do this using only Functoids? I tried to use Looping functoid but I don't understand how to extract every iteration. On the other hand I don't understand if I can use Table looping and Table extractor since actually I don't have a table.

So I need something like you can see at the picture. Actually task is even more complicated but let's start from this.

Does anyone know if this can be solved only by Functoids?

I would appreciate any advice..

Picture of what I need to do


Solution

  • You want the Iteration functoid and the Equal functoid.

    Link Note to each of the FreeText nodes and also to the Iteration functoid. Link that to a series of equal functoids with values of ranging from 2 to 5 and link those to the FreeText nodes as well.

    enter image description here

    Input file

    <ns0:Root xmlns:ns0="http://Scratch.SO65382125in">
      <Note>Note_0</Note>
      <Note>Note_1</Note>
      <Note>Note_2</Note>
    </ns0:Root>
    

    Output (formatted)

    <ns0:Root xmlns:ns0="http://Scratch.SO65382125out">
        <FreeText1>Note_0</FreeText1>
        <FreeText2>Note_1</FreeText2>
        <FreeText3>Note_2</FreeText3>
    </ns0:Root>
    

    Note that it works without a Looping Functoid but does show the warning

    The destination node "FreeText2" has multiple inputs. For a destination node to have multiple inputs, one of its ancestors should be connected to a looping functoid.

    You can get rid of that warning by adding a Looping Functoid

    enter image description here