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

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -