XSLT <xsl:attribute>
❮ Kompletní reference prvků XSLT
Definice a použití
Element <xsl:attribute> se používá k přidávání atributů do prvků.
Poznámka: Element <xsl:attribute> nahrazuje existující atributy ekvivalentními názvy.
Syntax
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
Atributy
Attribute | Value | Description |
---|---|---|
name | attributename | Required. Specifies the name of the attribute |
namespace | URI | Optional. Defines the namespace URI for the attribute |
Příklad 1
Přidejte atribut source k prvku obrázku:
<picture>
<xsl:attribute name="source"/>
</picture>
Příklad 2
Přidejte zdrojový atribut k prvku obrázku a vyplňte jej hodnotami z "images/name" :
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>
Příklad 3
Vytvořte sadu atributů, kterou lze použít na jakýkoli výstupní prvek:
<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>
❮ Kompletní reference prvků XSLT