<xsl:attribute-set name="attrs">
<xsl:attribute name="attr-count">
<xsl:value-of select="count(@*)"/>
</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="elements">
<xsl:attribute name="name">
<xsl:value-of select="name()"/>
</xsl:attribute>
<xsl:attribute name="node-count">
<xsl:value-of select="count(*)"/>
</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="*">
<xsl:element name="element"
use-attribute-sets="elements attrs">
<xsl:apply-templates select="*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<element name="a" node-count="1" attr-count="2">
<element name="d" node-count="0" attr-count="3"/>
</element>
В этом преобразовании определение элемента
<xsl:element name="element"
use-attribute-sets="elements attrs">
<xsl:apply-templates select="*"/>
</xsl:element>
равносильно определению