How to generate XML containing multiple sequences

Highlighted
Two Stars

How to generate XML containing multiple sequences

I have a positional file that I need to convert to a number of XML files. Unfortunately the XML structure has two, separate, sequences which tAdvancedFileOutputXML cannot support (I can only specify a single looping element).

Example Input
HEADER
000001P123R1
000001P123R2
000001P154
000002P101R1
000002P123R2
000002P1107R1
000002P125R5
TRAILER

Example Output
<Customer>
    <Id>000001<Id>
    <Name>Joe Dance</Name>
    <Products>
        <Id>123</Id>
        <Id>123</Id>
        <Id>154</Id>
    </Products>
    <Rewards>
        <Id>1</Id>
        <Id>2</Id>
    </Rewards>
</Customer>

<Customer>
    <Id>000002<Id>
    <Name>John Smith</name>
    <Products>
        <Id>101</Id>
        <Id>123</Id>
        <Id>120</Id>
        <Id>125</Id>
    </Products>
    <Rewards>
        <Id>1</Id>
        <Id>2</Id>
        <Id>5</Id>
    </Rewards>
</Customer>


Below is a mocked structure of the current job:
Example JobExample Job

Two questions:
1. What is the preferred approach ?
2. If I continue with this solution how do I make sure that the 3 inputs on the right wait for the tAdvancedFileOutXML components to finish and how do I trigger them ? I tried a linked set of tWaitForFile but that didn't seem to work as expected.


Accepted Solutions
Sixteen Stars
Sixteen Stars

Re: How to generate XML containing multiple sequences

Use a onSubjobOk trigger between tFileInputPositional_1 and tFileInputXML_1, then the 2nd subjob will start only after the 1st one have finished.


TRF

View solution in original post


All Replies
Sixteen Stars
Sixteen Stars

Re: How to generate XML containing multiple sequences

Use a onSubjobOk trigger between tFileInputPositional_1 and tFileInputXML_1, then the 2nd subjob will start only after the 1st one have finished.


TRF

View solution in original post

Highlighted
Community Manager

Re: How to generate XML containing multiple sequences

You might want to use a similar solution to the one I have described here but for JSON (https://community.talend.com/t5/Design-and-Development/How-to-Denormalize-a-JSON-source/m-p/26161#U2...). You would use tExtractXMLField components rather than the JSON equivalent (and will need a bit of  XPath knowledge). 

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog