Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Adam_Bender
Contributor
Contributor

Need Help with XML mapping - create XML with multiple loops of unrelated items in a single XML document output

Hi,

 

We use the subscription version of Talend and need help creating a very specific XML document for use in an API process.  The XML structure has 2 elements that are unrelated to one another, but which can each have multiple values.

 

The pieces I'm interested in understanding are the looped elements accounts and levels.

 

Other important info: the values that will be used to generate the accounts and levels will come from a database connection and are stored in a table with the attributes needed in the XML output.

 

The XML structure is shown below.

 

EXAMPLE API REQUEST FORMAT

<?xml version='1.0' encoding='UTF-8'?> <call method="exportData" callerName="a string that identifies your client application"> <credentials login="sampleuser@company.com" password="my_pwd" instanceCode="INSTANCE1"/> <version name="Budget 2014" isDefault="false"/> <format useInternalCodes="true" includeUnmappedItems="false"/> <filters>    <accounts>      <account code="A100" isAssumption="true" includeDescendants="false"/>      <account code="L100" isAssumption="false" includeDescendants="true"/>    </accounts>    <levels>      <level name="Development" isRollup="true" includeDescendants="true"/>      <level name="QA" isRollup="false" includeDescendants="false"/>    </levels>    <timeSpan start="11/2013" end="12/2014"/>    <dimensionValues>      <dimensionValue dimName="Customer" name="A Corp" directChildren="true"/>      <dimensionValue dimName="Region" name="" uncategorized="true" directChildren="false"/>    </dimensionValues> </filters> <dimensions>    <dimension name="Product"/>    <dimension name="CountryRegion"/> </dimensions> <rules includeZeroRows="false" includeRollups="false" markInvalidValues="false" markBlanks="false" timeRollups="single">    <currency useCorporate="false" useLocal="false" override="AUD"/> </rules> </call>

I have tried tXMLMap with no success, it keeps outputting a separate documents each time it finds another account or level value but I need it in one single document.  I have also tried to understand the data mapper, but do not understand how to use it.

Labels (4)
3 Replies
Anonymous
Not applicable

You can do this with Talend Data Mapper using the tHMap. It is a bit different from the rest of the Talend Components though. You will probably need to either take training in it or to do A LOT of research in how to use it. Once you understand it, it can be very powerful, but it is far too difficult to explain the ins and outs of this via a question and answer process here. 

 

Alternatively you can use a trick with a couple of tXMLMap components. This might be easier to follow if you are familiar with these components. I have described a solution to a similar problem here....

https://community.talend.com/t5/Design-and-Development/Multiple-Nested-loop-in-outputXML/m-p/82289

Adam_Bender
Contributor
Contributor
Author

Hello,

 

I am familiar with data mapper, but don't completely understand how to use it.  That is the solution I would like to use, but I can't find much online that discusses how to create multiple loop sections.

I have successfully created multiple loops using tXMLMap, but when I select the checkbox that's supposed to combine the output into a single document it still returns multiple mini-documents.

 

Questions:

1. Can you point me to anything online that clearly explains how to use data mapper to do this?

2. Have you ever experienced tXMLMap not aggregating into a single document?  If so, how do you fix this?

Anonymous
Not applicable

The post I sent you describes how to combine multiple loops using several tXMLMap components using String manipulation.

 

For Data Mapper help, go to the Knowledge Base. A good place to start is here: https://community.talend.com/t5/Design-and-Development/Talend-Data-Mapper-Intro-Part-2-Using-the-Dat...

 

Search "Talend Data Mapper" in the Knowledge Base and you will find other articles/videos