One Star

[resolved] tXMLMap - get only first expression filtered row

Hi all,
Im working with a tXMLMap in extracting some fields from an XML file into single variables. I have an expression filter in the output row on a certain tag in the XML, which works fine since I am getting the expected rows.
But, I only need to get the first filtered row and send it to a tJavaRow component, how is this possible? (I can tell it loops since it prints the same outputs over the number of rows returned)
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] tXMLMap - get only first expression filtered row

...tXMLMap---main--tMap--out1--tJavaRow
on tMap, add a new variable called var1 in Var table, and set its expression values as:
Numeric.sequence("s1",1,1)
In the output table of tMap, add a filter expression to filter only the first row:
Var.var1==1

I hope this helps!
----------------------------------------------------------
Talend | Data Agility for Modern Business
7 REPLIES
Community Manager

Re: [resolved] tXMLMap - get only first expression filtered row

Hi 
You may add a sequence id to each row on a tMap and filter the first row.
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tXMLMap - get only first expression filtered row

Hi shong,
Thanks for the suggestion, but can you give me an example of this solution? I cant seem to grasp the actual implementation.
Community Manager

Re: [resolved] tXMLMap - get only first expression filtered row

...tXMLMap---main--tMap--out1--tJavaRow
on tMap, add a new variable called var1 in Var table, and set its expression values as:
Numeric.sequence("s1",1,1)
In the output table of tMap, add a filter expression to filter only the first row:
Var.var1==1

I hope this helps!
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tXMLMap - get only first expression filtered row

Hi shong,
The added variable works, thanks. But I have another problem:
I am adding a filter expression in the output row (String variable) of the tXMLMap, which returns 2 or more instances from the input row XML (Document variable). How can I set it to only return 1 row from the filtered expression?
Example: I am sending an XML that has a loop of 10 operators, and from my filter expression, I got 7 available operators. How can I make the mapping/looping/filtering only pass to the next component only 1 available operator?
Community Manager

Re: [resolved] tXMLMap - get only first expression filtered row

Hi 
What's  your filter expression? Can you give me an example to explain your problem?
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tXMLMap - get only first expression filtered row

Im filtering it with a value in an element in the XML shong.
Example: I am sending an XML that has a loop of 10 operators, and from my filter expression, I got 7 available operators. How can I make the mapping/looping/filtering only pass to the next component only 1available operator?
Community Manager

Re: [resolved] tXMLMap - get only first expression filtered row

As I said, add a sequence ID to the 7 operators on another tMap and filter the first line.
----------------------------------------------------------
Talend | Data Agility for Modern Business