XSLT <xsl:attribute> Element | Rookie Tutorial
Rookie Tutorial -- Learn not just technology, but also dreams!- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
XSLT Tutorial
- XSLT Tutorial
- XSL Languages
- XSLT Introduction
- XSLT Browsers
- XSLT Transformation
- XSLT <template>
- XSLT <value-of>
- XSLT <for-each>
- XSLT <sort>
- XSLT <if>
- XSLT <choose>
- XSLT Apply
- XSLT Client
- XSLT Server
- XSLT Edit XML
- XML Editor
- XSLT Summary
- XSLT Examples
- XSLT Elements
- XSLT Functions
- XSLT Transformation Tool
Deep Dive
Web Service
Computer Science
Scripting
Programming Languages
Scripting Languages
Search
Programming
Web Design and Development
Software
Web Services
XSLT <xsl:attribute> Element
Complete XSLT Element Reference
Definition and Usage
The <xsl:attribute> element is used to add an attribute to an element.
Note: The <xsl:attribute> element replaces an existing attribute with the same name.
Syntax
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
Attributes
| Attribute | Value | Description |
|---|---|---|
| name | attributename | Required. Specifies the name of the attribute. |
| namespace | URI | Optional. Defines the namespace URI for the attribute. |
Example 1
Add a source attribute to the picture element:
<picture>
<xsl:attribute name="source"/>
</picture>
Example 2
Add a source attribute to the picture element and assign it a value from "images/name":
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>
Example 3
Create an attribute set that 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>
YouTip