A student of mine recently contacted me to ask options for the following functionality.
An incoming message must be duplicated 3 times within a new message. So, as example
<Incoming> <ItemID>1</ItemID> <Quantity>2</Quantity> <CustomerID>3</CustomerID></Incoming>
should be transformed into
<NewMessage> <Incoming> <ItemID>1</ItemID> <Quantity>2</Quantity> <CustomerID>3</CustomerID> </Incoming> <Incoming> <ItemID>1</ItemID> <Quantity>2</Quantity> <CustomerID>3</CustomerID> </Incoming> <Incoming> <ItemID>1</ItemID> <Quantity>2</Quantity> <CustomerID>3</CustomerID> </Incoming></NewMessage>
My first instinct was to open up the mapper and use a “Looping” functoid. So, I drag & drop the “Looping” functoid, start to fill in.... Doh! That’s when I woke up and realized the “Looping” and “Table Looping” functoids are “source looping” (i.e. for each) while I was looking for a “destination looping” (i.e. for next).
Knowing the 'solves almost anything' external assembly option, I was convinced it is doable in the mapper. What I ended up with is a map with exactly 1 scripting functoid in there. An inline XSLT call-template allowed me to do exactly what I wanted.
As usual, Enjoy and comments are very welcome.
Remember Me