<xslTutorial creator="nicmila@idoox.com">
<index keywords="xsl:copy use-attribute-sets xsl:attribute-set"/>

<description>The xsl:copy element may have a use-attribute-sets attribute. In this way attributes for copied element can be specified. <stylesheet id='id3'/> does not work as expected (setting use-attribute-sets with name function)., because expresions in attributes that refer to named XSLT objects are not evaluated. Look at <example id="ex31"/> for more details.</description>

<xmlSource id="id1">
<H1>GREETING</H1> 
<P>Hello, world!</P> 
</xmlSource>

<attValues>
<value match="">
</value>
</attValues>

<xslStylesheet id="id2">
<xsl:template match="/">
<xsl:apply-templates select="/xslTutorial/*"/>
</xsl:template>

<xsl:template match="H1">
<xsl:copy use-attribute-sets='H1'>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>

<xsl:template match="P">
<xsl:copy use-attribute-sets='P     '>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>

<xsl:attribute-set name="H1"> 
 <xsl:attribute name='align'>center</xsl:attribute> 
 <xsl:attribute name='style'>color:red</xsl:attribute> 
 </xsl:attribute-set>
 
 <xsl:attribute-set name="P"> 
 <xsl:attribute name='align'>left</xsl:attribute> 
 <xsl:attribute name='style'>color:blue</xsl:attribute> 
 </xsl:attribute-set> 
</xslStylesheet>

<xslStylesheet id="id3">
<xsl:template match="/">
<xsl:apply-templates select="/xslTutorial/*"/>
</xsl:template>

<xsl:template match="*">
<xsl:copy use-attribute-sets='{name(.)}'>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>


<xsl:attribute-set name="H1"> 
 <xsl:attribute name='align'>center</xsl:attribute> 
 <xsl:attribute name='style'>color:red</xsl:attribute> 
 </xsl:attribute-set>
 
 <xsl:attribute-set name="P"> 
 <xsl:attribute name='align'>left</xsl:attribute> 
 <xsl:attribute name='style'>color:blue</xsl:attribute> 
 </xsl:attribute-set> 
</xslStylesheet>


</xslTutorial>