get attribute name
File: Data.xml <poem year="1667" type="epic"> <verse>line 3</verse> <verse>line 4</verse> </poem> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" omit-xml-declaration="yes" indent="no" /> <xsl:template match="poem"> <xsl:element name="{@type}"> <author>John</author> <year> <xsl:value-of select="@year" /> </year> <xsl:apply-templates /> </xsl:element> </xsl:template> <xsl:template match="verse"> <verse> <xsl:apply-templates /> </verse> </xsl:template> </xsl:stylesheet> Output: <epic><author>John</author><year>1667</year> <verse>line 3</verse> <verse>line 4</verse> </epic>