xslt - XML How to count based on subgroups -
i have 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 number of clients per country 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 count number of clients per continent?
try
<xsl:for-each select="countries/continent"> <xsl:value-of select="concat(@name, ': ', count(key('clientcountry', country)))"/> </xsl:for-each>
Comments
Post a Comment