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.

  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Nine Stars TRF
Nine 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
2 REPLIES
Nine Stars TRF
Nine 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
Eleven Stars

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). 

Rilhia Solutions