If you have a large document, you probably want to use the "Muenchian Method", which is usually used for grouping, to identify the distinct nodes. Declare a key that indexes the things you want to count by the values that are distinct:
<xsl:key name="artists-by-country" match="Artist_by_Country" use="Country" />
Then you can get the <Artist_by_Country>
elements that have distinct countries using:
/Artists_by_Countries
/Artist_by_Country
[generate-id(.) =
generate-id(key('artists-by-country', Country)[1])]
and you can count them by wrapping that in a call to the count()
function.
Of course in XSLT 2.0, it's as simple as
count(distinct-values(/Artists_by_Countries/Artist_by_Country/Country))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…