<pooh>
After breakfast they went round to see Piglet and Pooh
explained as they went that Piglet was a very small animal
who did not like bouncing and asked Tigger who had been
hiding behind trees said that a Tigger was only bouncy before
breakfast and that as soon as they had had breakfast they became
quiet and refined
</pooh>
<xsl:template match="pooh">
<wordcount>
<xsl:for-each-group group-by="."
select="for $w in tokenize(string(.), '\W+') return lower-case($w) ">
<xsl:sort select="count(current-group() )" order="descending" />
<word word="{current-grouping-key() }"
frequency="{count(current-group() ) }"/>
</xsl:for-each-group>
</wordcount>
</xsl:template>
- Group by words
- Sort in frequency of word appearance
- Output word and frequency in which it occurs