xsl:attribute

Creates an attribute.

Format

Description

You can specify the xsl:attribute instruction in the

l Contents of a stylesheet element that creates a result element
l Contents of an xsl:attribute-set instantiation

In a stylesheet element that creates a result element, the xsl:attribute instruction causes an attribute to be added to the created result element.

The prefix part of the name attribute value becomes the prefix for the attribute you are creating. The local part of the name attribute value becomes the local name of the attribute you are creating.

The XSLT processor interprets the name attribute as an attribute value template. The string that results from instantiating the attribute value template must be a qualified name. If it is not, the XSLT processor reports an error.

The result of instantiating the content of the xsl:attribute instruction is used as the value of the created attribute. It is an error if instantiating this content generates anything other than characters.

If you add an attribute to an element and that element already has an attribute with the same expanded name, the attribute you are creating replaces the existing attribute.

Example

 
Free Stylus Studio XML Training: