XSLT <xsl:attributo>
❮ Completa il riferimento agli elementi XSLT
Definizione e utilizzo
L'elemento <xsl:attribute> viene utilizzato per aggiungere attributi agli elementi.
Nota: l'elemento <xsl:attribute> sostituisce gli attributi esistenti con nomi equivalenti.
Sintassi
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
Attributi
Attribute | Value | Description |
---|---|---|
name | attributename | Required. Specifies the name of the attribute |
namespace | URI | Optional. Defines the namespace URI for the attribute |
Esempio 1
Aggiungi un attributo sorgente all'elemento immagine:
<picture>
<xsl:attribute name="source"/>
</picture>
Esempio 2
Aggiungi un attributo sorgente all'elemento dell'immagine e riempilo con i valori di "images/name":
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>
Esempio 3
Crea un set di attributi che può essere applicato a qualsiasi elemento di output:
<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>
❮ Completa il riferimento agli elementi XSLT