apply-templates_2-input.xml
<?xml version="1.0"?>
<products>
<product
id="p1" name="Delta" price="3250" stock="4"/>
<product
id="p2" name="Golf" price="1000" stock="5"/>
<product
id="p3" name="Alpha" price="1200" stock="19"/>
<product
id="p4" name="Foxtrot" price="1500" stock="5"/>
<product
id="p5" name="Tango" price="1225" stock="3"/>
</products>
apply-templates_2-stylesheet.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output
indent="yes"/>
<xsl:template
match="*">
<xsl:element
name="{upper-case(name(.))}">
<xsl:apply-templates
select="@*|*"/>
</xsl:element>
</xsl:template>
<xsl:template
match="@*">
<xsl:copy/>
</xsl:template>
<xsl:template
match="@name">
<xsl:attribute
name="label"><xsl:copy/></xsl:attribute>
</xsl:template>
<xsl:template
match="product[@id = 'p4']"/>
</xsl:stylesheet>
apply-templates_2-output.xml
<?xml version="1.0" encoding="UTF-8"?>
<PRODUCTS>
<PRODUCT
id="p1" label="Delta" price="3250" stock="4"/>
<PRODUCT
id="p2" label="Golf" price="1000" stock="5"/>
<PRODUCT
id="p3" label="Alpha" price="1200" stock="19"/>
<PRODUCT
id="p5" label="Tango" price="1225" stock="3"/>
</PRODUCTS>
The upper-case() function is new in XSLT 2.0. In XSLT 1.0 we can use tranlate().
Updated 2009-03-19