Create new element with attribute
File: Data.xml <?xml version="1.0"?> <?xml-stylesheet href="Transform.xslt" type="text/xsl"?> <message>Message.</message> File: Transform.xslt <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <xsl:element name="paragraph"> <xsl:attribute name="priority">medium</xsl:attribute> <xsl:attribute name="date">2003-09-23</xsl:attribute> <xsl:attribute name="doc:style" namespace="http://www.java2s.com/documents">classic</xsl:attribute> <xsl:apply-templates /> </xsl:element> </xsl:template> </xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?> <paragraph xmlns:doc="http://www.java2s.com/documents" priority="medium" date="2003-09-23" doc:style="classic">Message.</paragraph>