XML Output issue

One Star

XML Output issue

Hi everyone,

I am currently using a tAdvancedFileXMLOutput component to create an XML file at the end of my job, but the output doesn't look exactly like how I want it to be. Since I have very little experience working with XML files, perhaps you can help.

My XML looks like this:

EDOC
        Header
                 Sub-Element 1
                 Sub-Element 2
                 Sub-Element 3
                 Sub-Element 4
                 ...
        Detail
                 Sub-Element 10
                 Sub-Element 11
                 Sub-Element 12
                 Sub-Element 13
                 ...
Header has some general information about my document and detail contains several different order lines.
In the detail section, I have an element called "line type". I have two types: 1 and TG. 
Now for each document, I would like to have these different types of lines grouped together. For example, Document No: 15 will have both TG and 1 lines in its detail section, however when I create my output file, both TG and 1 lines each get the same header. So currently the end result looks like this:
Header
Doc No: 15
Detail
Line Type 1

Header
Doc No: 15
Detail
Line Type TG

But my goal is to have:

Header
Doc No: 15
Detail
Line Type 1
Line Type TG

I am most likely missing something or not setting my loop or group elements properly. Any ideas?

Thanks,

Cihan
One Star

Re: XML Output issue

I'm not sure if this will help, but couldn't you use a tXMLMap before hand/instead with the All in one option? Seemed to solve a similar problem for me, although I wasn't writing out to XML (was transforming the output to JSON).
One Star

Re: XML Output issue

OK, I have taken a look at tXMLMap (first time I've heard of it) and if I am not wrong, it works like tMap, but you can select loop elements, add sub-elements, etc. Is that right? How does "all in one" work?
My current job looks like this:

The only thing that is screwing things up is the different line types, but I am somehow unable to bring different types under the same detail section.
One Star

Re: XML Output issue

cihanc83 wrote:
OK, I have taken a look at tXMLMap (first time I've heard of it) and if I am not wrong, it works like tMap, but you can select loop elements, add sub-elements, etc. Is that right? How does "all in one" work?
My current job looks like this:

The only thing that is screwing things up is the different line types, but I am somehow unable to bring different types under the same detail section.

Firstly, select the tXMLMap component and open the Map Editor from it's settings/properties. This is similar (slightly) to the mapping defined in the tAdvancedFileXMLOutput component, dragging stuff from the left into the structure you define on the right. The difference here is there's a "spanner" button at the top of the output block, which is pressed illustrates global options, including "All in one". In example, this is what id did for me:
Before:
<CarParks><CarPark id="1">...</CarPark></CarParks>
<CarParks><CarPark id="2">...</CarPark></CarParks>
After:
<CarParks><CarPark id="1">...</CarPark><CarPark id="2">...</CarPark></CarParks>
Try it, tLogRow it, and check the output until it's what you are looking for.
One Star

Re: XML Output issue

Thanks, is it possible to link the results to some other component instead of tlogrow? I have so many fields that the end result is jumbled and hard to read.
If anyone has other suggestions, I'd also like to read them.
One Star

Re: XML Output issue

cihanc83 wrote:
Thanks, is it possible to link the results to some other component instead of tlogrow? I have so many fields that the end result is jumbled and hard to read.
If anyone has other suggestions, I'd also like to read them.

Well, I suppose you can just use an appropriate writer and then take a look at the output. I personally, would use a tLogRow, and copy and paste the XML into something that can format it to verify the output structure.
One Star

Re: XML Output issue

OK, you can link a tFileOutputXML to tXMLMap and then select "Incoming record is a document" on the Output component. That gives you the result as an XML file.
That said... my lines are still separated based on their types. It is driving me crazy to be honest. There is something else going on I think, I am not sure.
What did you select as your loop element for your job? For example, in your CarPark case.
One Star

Re: XML Output issue

Good point, looking at your example in the first post I would have selected the DETAIL parent as the loop element, especially with All in one set to true.
One Star

Re: XML Output issue

OK, bad news. I have done it and it didn't work. Thanks for the help by the way, appreciated.

If there are any further suggestions, by all means...
One Star

Re: XML Output issue

cihanc83 wrote:
OK, bad news. I have done it and it didn't work. Thanks for the help by the way, appreciated.

If there are any further suggestions, by all means...

If I spot anything else in the forums that might help I'll point you to it, but I'm dried up now. Only been using Talend for about 2 weeks anyway, so hopefully someone else will pick this up and answer.
One Star

Re: XML Output issue

Hi guys,
Sorry to resurrect an old thread, but I am still suffering from the same problem described in my very first post.
Any ideas?
Cihan
Seventeen Stars

Re: XML Output issue

hi,

not sure but try to put your detail as sub element of line (EDI LINE NUMBER) element (in your first attempt with multi-schema xml output).
tXmlmap is very useful when your have a multi-schema to read (among other things )

regards
laurent

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog