One Star

[resolved] tXMLMap loop through root and child nodes.

Hello,
I have a problem regarding loops in tXMLMap. Since TXmlMap doesnt allow to have a loop on both root and child elements, I cant seem to figure out the way to complete my task. I need to send payload to tESBProviderResponse with same schema as a response from a web service. I marked the elements that should be looped through in the image, and also provided with a way my response should look like.
LINK TO THE IMAGE: http://postimg.org/image/g7hjsv7gf/full/
Can anyone link me to a tutorial on that would solve this problem, or supply me with a solution?
Thank you in advance,
Algimantas
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

Solved this problem by simply using tMap instead of tXMLMap and just threw the payload i get from tESBConsumer straight to tESBResponse, thus skipping the mapping part where i had to deal with multiloops.
10 REPLIES
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

spiderman - if you've not solved your issue yet, I'm wondering if you've tried the tFileOutputMSXML component that allows for looping at parent and child nodes?
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

havent solved it yet. As i said i need to send a payload i receiver from TESBConsumer to tESBProviderResponse componet, not to a file.
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

Solved this problem by simply using tMap instead of tXMLMap and just threw the payload i get from tESBConsumer straight to tESBResponse, thus skipping the mapping part where i had to deal with multiloops.
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

I just want to know how did you solve this with tmap. Did you join the two loop results using tmap?
I need help here.
Thanks,
suviga
Employee

Re: [resolved] tXMLMap loop through root and child nodes.

For future reference, the tExtractXMLField component is very useful when trying to extract data from XML with nested loops. But I guess as you simply want to pass from the input to output, you do not need to extract the data and rebuild it :-)
Suviga, he didn't extract any data. He simply passed the data as a Document through the tMap. If you want to extract data from nested loops, then look at the tExtractXMLField component. You will also need to look at XPath queries to get the best use out of this.
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

rhel, I think my scenario is completely different.
<root>
<items>
</item>
</item>
</items>
<places>
</place>
</place>
</places>
</root>
I am able to set loop in both  item and place (since they are in same level)  using tXMLMap
But if I want one more loop at a city node(which is a child of  place)
<root>
<items>
</item>
</item>
</items>
<places>
<place>
<cities>
</city>
</city>
</cities>
</place>
<place>
<cities>
</city>
</city>
</cities>
</place>
</places>
</root>
I am not able to achieve this as loops can't be set both at parent and child level.
Note: Link to references if any will be helpful as I am very new to Talend
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

And also for your information I have to do a lot of transformation & filtering on these  loops,It is not just simple mapping.
Employee

Re: [resolved] tXMLMap loop through root and child nodes.

Take a look at the tExtractXMLField component. You can use these components in combination to extract multiple loops (nested as well), but it takes a little work. I don't have any links to demonstrate this I am afraid. But your question has got me thinking about a good tutorial to write :-)
Consider extracting the elements containing looped data as "nodes" using the tExtractXMLField component. Then pass those nodes to subsequent tExtractXMLField components to extract the detail data from those nodes. Take a look at the Talend documentation on the component to see how this is done. 
I will put together a tutorial on this and when it is online I will share the link.
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

Thanks a lot rhall for your faster replies Smiley Happy.Will try with tExtractXMLField
One Star

Re: [resolved] tXMLMap loop through root and child nodes.

Rhall,
I am struck here again.
In tExtractyXMLfiled We can iterate through loops.
But after that I need to filter only those Whose parent's parameters are validated against certain expectations.
I want to get the country where the address type = Physical and valid = yes .
Am using tXMLMap, I have put the Loop at address level and then Filtering the items in expression builder where address type = Physical.But I don't know how to check " valid = yes "
Example:
<Locations>
<location valid="yes">
<contact>
<address>
<type>LL</type>
<country>ES</country>
</address>
<address>
<type>Physical</type>
<country>IT</country>
</address>
</contact>
</location>
<location  valid="no">
<contact>
<address>
<type>LL</type>
<country>GB</country>
</address>
<address>
<type>Physical</type>
<country>MI</country>
</address>
</contact>
</location>
</Locations>