left up
Attribute Sets

Sometimes you want to add a standard set of attributes. The top-level element xsl:attribute-set is defined for that purpose

<xsl:stylesheet>
<xsl:attribute-set name="numbering">
  <xsl:attribute name="number"><xsl:value-of select="position()" />
  </xsl:attribute>
  <xsl:attribute name="from"><xsl:value-of select="last()" />
  </xsl:attribute>
</xsl:attribute-set>
<xsl:template match="cdlist">
  <xsl:copy>
  <xsl:for-each select="cd">
    <xsl:copy use-attribute-sets="numbering">
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:for-each>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>

This would create a cd element of the form:

<cd number="73" from="930" >
...