XSLT <xsl:copy-of> 요소

정의와 사용법

<xsl:copy-of> 요소는 현재 노드의 복사본을 생성할 수 있습니다.

주의사항:현재 노드의 Namespace 노드, 자식 노드 및 속성은 자동으로 복사됩니다!

추천:이 요소는 동일한 노드의 여러 복사본을 출력의 다른 위치에 삽입할 수 있습니다.

문법

<xsl:copy-of select="표현식"/>

속성

속성 설명
선택 표현식 필수. 복사할 내용을 지정합니다.

예시

예제 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="header">
  <tr>
  <th>요소</th>
  <th>설명</th>
  </tr>
</xsl:variable>
<xsl:template match="/">
  <html>
  <body>
  <table>
    <xsl:copy-of select="$header" />
    <xsl:for-each select="reference/record">
    <tr>
    <xsl:if test="category='XML'">
      <td><xsl:value-of select="element"/></td>
      <td><xsl:value-of select="description"/></td>
    </xsl:if>
    </tr>
    </xsl:for-each>
  </table>
  <br />
  <table>
    <xsl:copy-of select="$header" />
    <xsl:for-each select="table/record">
    <tr>
    <xsl:if test="category='XSL'">
      <td><xsl:value-of select="element"/></td>
      <td><xsl:value-of select="description"/></td>
    </xsl:if>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>