XSLT <xsl:attribute>Elemento


XSLT 元素参考手册Referencia completa de elementos XSLT

Definición y uso

El elemento <xsl:attribute> se utiliza para agregar atributos a un elemento.

Nota: el elemento <xsl:attribute> reemplaza los atributos existentes con el mismo nombre.


Sintaxis

<xsl:attribute name="attributename" namespace="uri">

<!-- Content:template -->

</xsl:attribute>

Atributos

Atributo Valor Descripción
name attributename Requerido. Especifica el nombre del atributo.
namespace URI Opcional. Define el URI del espacio de nombres para el atributo.

Ejemplo 1

Agrega el atributo source al elemento picture:

<picture>
<xsl:attribute name="source"/>
</picture>

Ejemplo 2

Agrega el atributo source al elemento picture y asígnale el valor de "images/name":

<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</picture>

Ejemplo 3

Crea un conjunto de atributos que se puede aplicar a cualquier elemento de salida:

<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>


XSLT 元素参考手册Referencia completa de elementos XSLT Otras extensiones