XSLT 元素参考手册 完整的 XSLT 元素参考手册 The < xsl:attribute > element is used to add attributes to the element. Note: the < xsl:attribute > element replaces existing attributes with the same name. Attribute Value Description Name Attributename Necessary. Specifies the name of the attribute. Namespace URI Optional. The URI that defines the namespace for the attribute. Add a source attribute to the picture element: Add a source attribute to the picture element and assign it using the value in “images/name”: Create a set of attributes that can be applied to any output element:Definition and usage ¶
Grammar ¶
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
Attribute ¶
Example 1 ¶
<picture>
<xsl:attribute name="source"/>
</picture>
Example 2 ¶
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>
Example 3 ¶
<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>