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
4 REPLIES
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.