你搞错了,XSLT里的变量是不能变的,在addressBook模板里,用
<xsl:value-of select="count(telephone)"/>要总计的话,用
<xsl:value-of select="count(//telephone)"/>

解决方案 »

  1.   

    你说的对, XSLT的变量是不能变的,但是有些情况下是可以做到的, 比如Eric M. Burke的<<Java and XSLT>>书上这样说:3.2.4 Incrementing Variables
    Unfortunately, there is no standard way to increment a variable in XSLT. Once a variable has
    been defined, it cannot be changed. This is comparable to a final field in Java. In some
    circumstances, however, recursion combined with template parameters can achieve similar
    results.上面是说可以根据模板参数和递归可以实现类似的效果, 我是想试试一下这种用法的.