..." />
<xsl:copy use-attribute-sets="numbering">
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:attribute-set name="numbering">
<xsl:attribute name="number"><xsl:number/></xsl:attribute>
<xsl:attribute name="total">
<xsl:value-of select="count(//PLANET)"/>
</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
Ниже показан результат; заметьте, что у каждого элемента <PLANET> есть оба атрибута, number и total, и атрибут total содержит общее число элементов <PLANET> в документе:
<?xml version="1.0" encoding="UTF-8"?>
<PLANETS>
<PLANET number="1" total="3">
<NAME>Mercury</NAME>
<MASS>.0553</MASS>
<DAY>58.65</DAY>
<RADIUS>1516</RADIUS>
<DENSITY>.983</DENSITY>
<DISTANCE>43.4</DISTANCE>
</PLANET>
<PLANET number="2" total="3">
<NAME>Venus</NAME>
<MASS>.815</MASS>
<DAY>116.75</DAY>
<RADIUS>3716</RADIUS>
<DENSITY>.943</DENSITY>
<DISTANCE>66.8</DISTANCE>
</PLANET>