Counting and filtering based on it, inside an xsl:for-each



I have a source XML generated automatically by a clumsy program, which contains repeated and empty entries.


I want to be able to select and show ONLY the entry the most represented, filtering the empty entries. For example, suppose my source XML is



<catalog>
<letter>
<char>A</char>
</letter>
<letter>
<char>B</char>
</letter>
<letter>
<char></char>
</letter>
<letter>
<char>A</char>
</letter>
<letter>
<char></char>
</letter>
<letter>
<char></char>
</letter>
</catalog>


Then, I want to get only A.


I can do:



<table><tr>
<xsl:for-each select="letter[char='']">
<td><xsl:value-of select="char" /></td>
</xsl:for-each>
</tr></table>


which will show me a table containing only A, B, A (not the empty columns).


Now I want to get only A, because it is the one that appears most often. How do I do it?


No comments:

Post a Comment