Reputation: 800
I have xml with following structure as datasource:
...
<addresses>
<address>
<!--... first address... -->
<country>
<shortName>Belarus</shortName>
<name>Republic of Belarus</name>
</country>
...
</address>
<address>
... more adresses ...
<country>
<shortName>Russia</shortName>
<name>Russian Federation</name>
</country>
... same fields ...
</address>
</addresses>
...
So I need to write jrxml template that gets the last address in addresses. When I use
<field name="regAddress_country_nameRu" class="java.lang.String">
<fieldDescription>
<![CDATA[addresses/address/country/shortName]]>
</fieldDescription>
</field>
It gets "Belarus" - value from first address, but how to get values from last address? I need to do it in iReport, so maybe I can do in GUI-style? Any solution will suit me well.
Upvotes: 1
Views: 1041
Reputation: 800
I found the answer. You can use function last() in XPATH expressions as pointed here. So to get las address in my example just need to modify expression:
<![CDATA[addresses/address[last()]/country/shortName]]>
It worked for me and I hope it will be helpful for you too :).
Upvotes: 1