You can't do it the way you are suggesting in XSLT, as variables cannot be updated. However you should be able to use the calculation which works out if it should display 'HEADER' to simply count the number of times that that would be displayed.
e.g.
in your template do something like this:
Code:
<xsl:if test="@Id='AB'">HEADER</xsl:if>
and then at the bottom:
Code:
There are <xsl:value-of select="count(//@Id='AB')"/> headers
/- Sam Judson : Wrox Technical Editor -/