XML record count

Seven Stars

XML record count

I have an XML file in the following format:
<Items>
<Item>
<Detail1>A</Detail1>
<Detail3>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
<Item>
<Detail2>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
...
</Items>
I want to read all the details in as normalised records so I set the Loop XPath to "/Items/Item//*" with columns "fn:name()" and ".". So far so good, I get records as follows:
Detail1,A
Detail3,B
etc.
But the problem is there is no unique identifier amongst the various details for each <Item> so how can I create one to link the various detail records, even if it's a simple counter of which <Item> the record is created from? I thought something with fnSmiley Tongueosition() but I can't make it work.
Thanks
Highlighted
One Star

Re: XML record count

Hi
Maybe create a job like this.
tFileInputXML --main-->tMap--main-->tLogRow
In the "outer" of tMap, add a new column and use this column to generate sequence id.
Regards,
Pedro
Seven Stars

Re: XML record count

That would give me a sequence that increments for each detail but I need a sequence that increments for each Item i.e. one level up from my loop.
Seven Stars

Re: XML record count

Anyone have any idea, please?
One Star

Re: XML record count

You could use the count() function in xslt and use the tXSLT component.

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now