XSLT <xsl:attribute> 要素
定義と使用法
<xsl:attribute> 要素は要素に属性を追加するために使用されます。
注釈:<xsl:attribute> 要素は同じ名前の既存属性を置き換えます。
構文
<xsl:attribute name="attributename" namespace="uri"> <!-- Content:template --> </xsl:attribute>
属性
属性 | 値 | 説明 |
---|---|---|
name | attributename | 必須です。属性の名前を指定します。 |
namespace | URI | オプションです。属性の命名空間の URI を定義します。 |
例
例 1
picture 要素に source 属性を追加します:
<picture> <xsl:attribute name="source"/> </picture>
例 2
picture 要素に source 属性を追加し、"images/name" 内の値を使用して設定します:
<picture> <xsl:attribute name="source"> <xsl:value-of select="images/name" /> </xsl:attribute> </picture>
例 3
どの出力要素にも適用できる属性セットを作成します:
<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>