我有以下数据:
<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>
我可以使用以下内容计算每个国家/地区的客户数量:
<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>
我如何计算每个大陆的客户数量?
答案 0 :(得分:1)
尝试
<xsl:for-each select="countries/continent">
<xsl:value-of select="concat(@name, ': ', count(key('clientcountry', country)))"/>
</xsl:for-each>