Elemento <xsl:attribute> do XSLT
Definição e uso
O elemento <xsl:attribute> é usado para adicionar propriedades a elementos.
Notas:O elemento <xsl:attribute> substitui o atributo existente com o mesmo nome.
Sintaxe
<xsl:attribute name="attributename" namespace="uri"> <!-- Conteúdo:template --> </xsl:attribute>
Atributo
Atributo | Valor | Descrição |
---|---|---|
name | attributename | Obrigatório. Especificar o nome da propriedade. |
namespace | URI | Opcional. Definir o URI da namespace para a propriedade. |
Exemplo
Exemplo 1
Adicionar a propriedade 'source' ao elemento 'picture':
<picture> <xsl:attribute name="source"/> </picture>
Exemplo 2
Adicionar a propriedade 'source' ao elemento 'picture' e atribuir o valor a partir de 'images/name':
<picture> <xsl:attribute name="source"> <xsl:value-of select="images/name" /> </xsl:attribute> </picture>
Exemplo 3
Criar um conjunto de atributos que pode 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>