I have a requirement to get distinct count of some particular element, but I have to only use a single XPath line to fulfil that requirement.
<root>
<Custom1>
<ZDPANR>PALLET1</ZDPANR>
</Custom1>
<Custom1>
<ZDPANR>PALLET3</ZDPANR>
</Custom1>
<Custom1>
<ZDPANR>PALLET1</ZDPANR>
</Custom1>
<Custom1>
<ZDPANR>PALLET1</ZDPANR>
</Custom1>
<Custom1>
<ZDPANR>PALLET2</ZDPANR>
</Custom1>
<Custom1>
<ZDPANR>PALLET2</ZDPANR>
</Custom1>
</root>
The code that I have tried so far is getting currently the distinct values for <ZDPANR> element.
<xsl:for-each select="//ZDPANR[not(.=following::ZDPANR) and .!='']">
<td>
<xsl:value-of select="count(//ZDPANR[.=(.)])"/><!--Single Xpath line where the count is not coming proper-->
</td>
</xsl:for-each>
I'm able to access current distinct ZDPANR using . inside for-each. But count(//ZDPANR[.=(.)]) (.) is not getting the current ZDPANR. If I hardcode count(//ZDPANR[.='PALLET2']) like this it's coming correctly. Therefore I want to get current ZDPANR in that hardcoded place.
Can somebody help me to achieve this? Because of a tool limitation I can only use Xpath 1.0.