Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
alevy
Specialist
Specialist

XML record count

I have an XML file in the following format:

 

<Items>

 <Item>

   <Detail1>A</Detail1>

   <Detail3>B</Detail3>

   <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 fn:position() but I can't make it work.

 

Thanks

Labels (3)
4 Replies
Anonymous
Not applicable

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
alevy
Specialist
Specialist
Author

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.
alevy
Specialist
Specialist
Author

Anyone have any idea, please?
janhess
Creator II
Creator II

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