xsl:number for attributes vs elements

This stylesheet, when applied to itself or any other stylesheet,
does the simple identity transformation, with a couple of additions:
Elements that have an attribute named 'match' will have an extra
attribute added: 'matchCount1'. The value of this attribute will be the
the result of <xsl:number level="any"/>, with the current node being the
'match' attribute.
In this context I would predict that the number inserted would be the
position of the attribute relative to all preceding 'match' attributes.
So I would expect that the first 'match' would be number 1, the second
would be number 2, and so on. However, SAXON says they're all number 1,
and XT, once the requisite adjustments are made for the lack of
match="node()" implementation, doesn't insert any number at all.
I also have elements named 'template' in the namespace assigned to the
prefix 'xsl' by this stylesheet (i.e., xsl:template elements) having a
'matchCount2' attribute added. The value of this attribute will be
the result of <xsl:number level="any"/>, with the current node being the
xsl:template element. In this context, I would predict the same results
-- the number inserted should be the position of the xsl:template element
relative to all preceding xsl:template elements. This works as expected
in SAXON, with the numbers being 1, 2 and 3 in order.
Am I misunderstanding what xsl:number should do here? I don't see why
attributes are treated differently than elements for counting purposes.
The stylesheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot; version="1.0">
<xsl:output method="xml" version="1.0" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@match">
<xsl:copy/>
<xsl:attribute name="matchCount1">
<xsl:number level="any"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="xsl:template">
<xsl:copy>
<xsl:attribute name="matchCount2">
<xsl:number level="any"/>
</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Result of applying the stylesheet to itself with SAXON 5.3.1:
<?xml version="1.0" encoding="utf-8" ?><xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot; version="1.0">
<xsl:output method="xml" version="1.0" indent="no"/>
<xsl:template matchCount2="1" match="node()|@*" matchCount1="1">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template matchCount2="2" match="@match" matchCount1="1">
<xsl:copy/>
<xsl:attribute name="matchCount1">
<xsl:number level="any"/>
</xsl:attribute>
</xsl:template>
<xsl:template matchCount2="3" match="xsl:template" matchCount1="1">
<xsl:copy>
<xsl:attribute name="matchCount2">
<xsl:number level="any"/>
</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list