タイトル
TOP → This Page

XML > XSLT > ノードのコピー

ノードのコピー


現在処理しているノードをコピーする場合は xsl:copy または xsl:copy-of を使う。
xsl:copy はカレントノードのみをコピーし、
xsl:copy-of は指定されたノード以下の全ノードをコピーする。

(書式)
<xsl:copy/>

または

<xsl:copy>
	テンプレート
</xsl:copy>

(書式)
<xsl:copy-of select="XPath 式"/>

(例)全ノードをコピー

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


TOP → This Page