XML & XSL - xsl:attribute


Creates an attribute node and attaches it to an output element.

Syntax

<xsl:attribute name=attribute-name>

Attributes

Parent Elements

Child Elements

Purpose

The contents of this element specify the value of the attribute. Attributes can be added or modified during transformation by placing the xsl:attribute element within elements that generate output, such as the xsl:copy element. Note that xsl:attribute can be used directly on output elements, and not only in conjunction with xsl:element. All attributes must be applied before children are added to the element.

The example below shows the setting of two attributes, VALUE and SIZE, in the creation of an element, an HTML FORM INPUT tag.

<xsl:element name="INPUT">
	<xsl:attribute name="VALUE"><xsl:value-of select="name"/></xsl:attribute>
	<xsl:attribute name="SIZE">35</xsl:attribute>
</xsl:element>

HTML Equivalent

<INPUT VALUE="name" SIZE="35">

Global Population Econometrics Example

Click here to view an example.