JasperReports: removing duplicate values ​​from a dataset

I want to print only unique values ​​from a dataset to a list component, avoiding duplicate values.

How to do it?

PS I am using XML as my data source.

+2


a source to share


2 answers


Try something like the following when selecting nodes in data source using X-Path.

/root/*[not(text() = preceding-sibling::*/text())]

      



It will select unique nodes for the XML structure like below.

<root>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node3>Data3</Node3>
</root>

      

0


a source


You can group this value, in your case Product

, grouping eliminates duplicates.



NOTE: data must be sorted for grouping to work

0


a source







All Articles