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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Creating XML with repeating elements

Hi,
I am trying to create an XML output using Delimited Input data. The output XML XSD has complex element type (repeating elements) to which I am unable to assign data.
Could you please help in this regard.
Sample Input
11|Sam|1|200|2|400|3|600
Expected Output
<?xml version="1.0" encoding="utf-8"?>
<OrdDet>
<CustID>11</CustID>
<CustName>Sam</custName>
<Orders>
<SubId>1</SubId>
<Amount>200</Amount>
</Orders>
<Orders>
<SubId>2</SubId>
<Amount>400</Amount>
</Orders>
<Orders>
<SubId>3</SubId>
<Amount>600</Amount>
</Orders>
</OrdDet>

Thanks in advance.
- Shankaran
Labels (2)
5 Replies
Anonymous
Not applicable
Author

Hi,
Could somebody help with this request.
Thanks in adavnce.
Regards
Shankaran
Anonymous
Not applicable
Author

Hello
Here is a demo,
in.csv:

11|Sam|1|200|2|400|3|600

Code on tJavaRow:
output_row.CustID = input_row.CustID;
output_row.CustName = input_row.CustName;
output_row.conn=input_row.SubId1+","+input_row.Amount1+";"+input_row.SubId2+","+input_row.Amount2+";"+input_row.SubId3+","+input_row.Amount3;

tLogRow:
Starting job ddd at 20:00 07/04/2010.
.------+--------+-----+------.
| tLogRow_1 |
|=-----+--------+-----+-----=|
|CustID|CustName|SubId|Amount|
|=-----+--------+-----+-----=|
|11 |Sam |1 |200 |
|11 |Sam |2 |400 |
|11 |Sam |3 |600 |
'------+--------+-----+------'
Job ddd ended at 20:00 07/04/2010.

out.xml:

<?xml version="1.0" encoding="ISO-8859-15"?>
<OrdDet>
<CustID>11</CustID>
<CustName>Sam</CustName>
<Orders>
<SubId>1</SubId>
<Amount>200</Amount>
</Orders>
<Orders>
<SubId>2</SubId>
<Amount>400</Amount>
</Orders>
<Orders>
<SubId>3</SubId>
<Amount>600</Amount>
</Orders>
</OrdDet>

Best regards
Shong
Anonymous
Not applicable
Author

Hello
However I have a query on the right approach when there are numerous complex element types (number of repeating elements is dynamic).

Output them into the same xml file one by one using the feature 'append the source xml file'. About 'append the source xml file', see 5975.
Best regards
Shong
Anonymous
Not applicable
Author

Hi Shong,
Thanks a lot for your reply. I am not sure if I posted by query correctly (or prob did not understand ''append the source xml file" feature correctly).
In the sample message posted above <AlternateID>, <PriceQuantityAssociation>, <Token>, <Account> are some of the repeating elements. The values required to populate these repeating elements will come in a single record from source (ie all the required values willbe part of column in a single message).
Going by the example job given by you earlier , to concatenate and then to normalise on the concatenated column to populate the repeating elements, my query was ,
would we need to normalise data the number of times we have repeating/group elements ?
Is there a better approach / or am I missing some link here ?
Please advise.
Thanks in advance.
-Regards
Shankaran
Anonymous
Not applicable
Author

Hi,
Could you please help with this request.
Thanks in advance.
Regards
Shankaran