องค์ประกอบ XSLT <xsl:copy-of>
คำนิยามและการใช้งาน
<xsl:copy-of> องค์ประกอบสามารถสร้างสำเนาของตัวเลือกปัจจุบัน
หมายเหตุ:Namespace ของตัวเลือกปัจจุบัน, ลูกตัวเลือก และคุณสมบัติจะถูกคัดลอกอัตโนมัติ!
คำแนะนำ:องค์ประกอบนี้สามารถใช้เพื่อใส่คัดลอกของตัวเลือกหลายตัวของตัวเลือกเดียวกันไปยังตำแหน่งต่าง ๆ ในการออกเสียง
วลี
<xsl:copy-of select="expression"/>
คุณสมบัติ
คุณสมบัติ | ค่า | คำอธิบาย |
---|---|---|
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>องค์ประกอบ</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>