xml文件:
<faculty>
<student name="a a" group="5">
<subject date="2013-02-01" name="science">124</subject>
</student>
<student name="q q" group="9">
<subject date="2013-02-01" name="my">124</subject>
</student>
<student name="z z" group="2">
</student>
<student name="v v" group="9">
<subject date="2013-02-01" name="tro">tro</subject>
</student>
</faculty>
需求:如何统计不超过2个科目的项目数。
我知道如何显示所有这些项目和科目数,但我不知道如何计算科目总数:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="name" match="subject" use="@name" />
<xsl:template match="subject">
<xsl:if test="count(key('name', @name)) < 2">
subject: <xsl:value-of select="@name" />
count: <xsl:value-of select="count(key('name', @name))" />
</xsl:if>
</xsl:template>
提前致谢