Name

<xsl:attribute>

Synopsis

This adds an attribute with the given name to an element in the result tree. Only one attribute with a particular name can be added to a specific element. The contents of the <xsl:attribute> element form the value of the attribute:

<xsl:element name="book">
<xsl:attribute name="title">Moby Dick</xsl:attribute>
<xsl:text>This is about a whale</xsl:text>
</xsl:element>

This creates the following element in the result tree:

<book title="Moby Dick">This is about a whale</book>

The optional namespace attribute specifies a namespace for the new attribute.

<xsl:attribute name="name"
   [namespace="namespace"]>
   ...
</xsl:attribute>

Get Webmaster in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.