Reputation: 107
I have the following data:
<countries>
<continent name="Europe">
<country>France</country>
<country>United Kingdom</country>
...
</continent>
<continent name="North America">
<country>Canada</country>
<country>United States</country>
...
</continent>
</countries>
<clients>
<client>
<name>John</name>
<country>Canada</country>
</client>
...
</clients>
I can count the number of clients per country with something like the following:
<xsl:key name="clientcountry" match="client" use="country"/>
<xsl:for-each select="countries//country">
<xsl:value-of select="concat(., ': ', count(key('clientcountry', .)))"/>
</xsl:for-each>
How can I count the number of clients per continent?
Upvotes: 0
Views: 46
Reputation: 167706
Try
<xsl:for-each select="countries/continent">
<xsl:value-of select="concat(@name, ': ', count(key('clientcountry', country)))"/>
</xsl:for-each>
Upvotes: 1