The problem is described below:
the source schema had a node similar to the one below
<BookingDetails reference="234" referencecode="FD453" creationdate="2011-10-11"/>
The idea was to create a repeatable node like the one below from this schema. Basically, if both reference and referencecode are passed in from the source, I need to create a new instance (in the destination schema) of the repeating node below for each of them, using the Instance attribute to show which one is mapped to each node as shown:
<ns1:BookingID Instance="ref" DT_Context="2011-10-11" ID="234" />
<ns1:BookingID Instance="refcode" DT_Context="2011-10-11" ID="FD543" />
Basically, if any of the reference and referencecode nodes is empty or null, the table looping functoid should not create a loop for that null or empty node
Of course, I could use xslt, but the table looping functoid and the table extractor functoids were used to solve the problem in a few seconds
The mapping solution goes as such:
- Add a table looping functoid to your map
- Add two table extractor functoids to the map
- Add the BookingDetails node as the first [0] input into your table looping functoid. This tells the functoid that this is the node from which the repeating structure will be created
- We are interested in 2 attributes (could also be nodes) because we want the table looping functoid to loop values based on reference and referencecode. Open up the table looping functoid and type in the integer 2 as the second [1] input to specify that we want two columns from the functoid
- Now add the attributes 'reference' and 'referencecode' as inputs [2] and [3] to specify that this is where the data for the first column will come from
- For inputs [4] and [5], type in the strings 'ref' and 'refcode' respectively to show that these will be thwe values in the second column
- Open the second (Table Looping) tab of the functoid.
- In row 1 column 1, select 'reference' as the first entry
- In row 1 column 2 select 'ref' as the entry
- In row 2 column 1, select 'referencecode' as the entry
- In row 2 column 2, select 'refcode' as the entry
- Tick the 'Gated' checkbox at the bottom of the tab to show that the first column will be used as the logical gate for the functoid, meaning that if any of the inputs in this column return nothing, the corresponding loop will not be created
- Drag a link to the BookingID node of the destination schema to show that this will be the repeating node
- Drag a link (as output) to the first table extractor functoid
- Drag a link (as output) to the second table extractor functoid
- Open up the first extractor functoid and type in the integer 1 as input [1] to show that this will extract the first row of the first column
- Open up the second extractor functoid and type in the integer 2 as input [1] to show that this will extract the second row of the first column
- Drag a link from the first extractor to the 'ID' attribute of the BookingID node in the destination to show that this output will be mapped to the 'ID' attribute in the repeating node
- Drag a link from the first extractor to the 'Instance' attribute of the BookingID node in the destination to show that this output will be mapped to the 'Instance' attribute in the repeating node
- Simply drag a link directly from the creationdate node on the source to the DT_Context node on the destination as this does not need to be passed into the table and will be created for every loop of the table
- Build the map
Input BookingDetails nodes
Case 1
<BookingDetails reference="234" referencecode="FD453" creationdate="2011-10-11"/>
Case 2
<BookingDetails referencecode="FD453" creationdate="2011-10-11"/>
Repeating Output BookingID nodes
Case 1
<ns1:BookingID Instance="ref" DT_Context="2011-10-11" ID="234" />
<ns1:BookingID Instance="refcode" DT_Context="2011-10-11" ID="FD543" />
Case2
<ns1:BookingID Instance="refcode" DT_Context="2011-10-11" ID="FD543" />
Hope this helps someone