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