XSLT <xsl:atributo>
❮ Referência Completa do Elemento XSLT
Definição e uso
O elemento <xsl:attribute> é usado para adicionar atributos aos elementos.
Nota: O elemento <xsl:attribute> substitui atributos existentes por nomes equivalentes.
Sintaxe
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
Atributos
Attribute | Value | Description |
---|---|---|
name | attributename | Required. Specifies the name of the attribute |
namespace | URI | Optional. Defines the namespace URI for the attribute |
Exemplo 1
Adicione um atributo de origem ao elemento de imagem:
<picture>
<xsl:attribute name="source"/>
</picture>
Exemplo 2
Adicione um atributo source ao elemento picture e preencha-o com valores de "images/name" :
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>
Exemplo 3
Crie um conjunto de atributos que possa ser aplicado a qualquer elemento de saída:
<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>
❮ Referência Completa do Elemento XSLT