XSLT <xsl:attribute> 요소

정의 및 사용법

<xsl:attribute> 요소는 요소에 속성을 추가하는 데 사용됩니다.

주의사항:<xsl:attribute> 요소는 이름이 같은 기존 속성을 대체합니다.

문법

<xsl:attribute name="attributename" namespace="uri">
  <!-- Content:template -->
</xsl:attribute>

속성

속성 설명
name attributename 必需. 속성 이름을 정의합니다.
네임스페이스 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>