Latest web development tutorials

XSLT <xsl: attribute> element

XSLT Elements Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

<Xsl: attribute> element is used to add attributes to elements.

NOTE: <xsl: attribute> element replaces an existing attribute with the same name.


grammar

<xsl:attribute name="attributename" namespace="uri">

<!-- Content:template -->

</xsl:attribute>

Attributes

属性 描述
name attributename 必需。规定属性的名称。
namespace URI 可选。为属性定义命名空间的 URI。

Example 1

Adding to the picture element source attributes:

<picture>
<xsl:attribute name="source"/>
</picture>

Example 2

Adding to the picture element source attributes, and use "images / name" in the value of their assignment:

<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>

Example 3

Create a set of attributes can be applied to any output element:

<xsl:attribute-set name="font">
<xsl:attribute name="fname">Arial</xsl:attribute>
<xsl:attribute name="size">14px</xsl:attribute>
<xsl:attribute name="color">red</xsl:attribute>
</xsl:attribute-set>


XSLT Elements Reference Manual Complete XSLT Element Reference Manual