XSLT <xsl:copy-of>
❮完全なXSLT要素リファレンス
定義と使用法
<xsl:copy-of>要素は、現在のノードのコピーを作成します。
注:名前空間ノード、子ノード、および現在のノードの属性も自動的にコピーされます。
ヒント:この要素を使用して、同じノードの複数のコピーを出力の異なる場所に挿入できます。
構文
<xsl:copy-of select="expression"/>
属性
Attribute | Value | Description |
---|---|---|
select | expression | Required. Specifies what to be copied |
例1
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="header">
<tr>
<th>Element</th>
<th>Description</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>
❮完全なXSLT要素リファレンス