Element <xsl:copy-of> ของ XSLT

คำอธิบายและการใช้งาน

Element <xsl:copy-of> สามารถสร้างสำเนาของตัวอย่างปัจจุบัน

หมายเหตุ:Namespace ของตัวนิพนธ์ปัจจุบัน รวมถึงข้อความลูกและแฟ้มแบบ Attribute จะถูกคัดลอกอัตโนมัติ!

คำเตือน:ตัวอย่างสำหรับใช้เพื่อใส่คัดลอกของข้อความเดียวกันของตัวอย่างในตำแหน่งต่างๆ ของออกที่แสดงผล

Grammar

<xsl:copy-of select="expression"/>

Attribute

Attribute ค่า การอธิบาย
select expression จำเป็นต้องมี。กำหนดเนื้อหาที่ต้องคัดลอก

ตัวอย่าง

ตัวอย่าง 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>Element</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>