<xsl:copy-of> | |
結果ツリーにコンテンツをコピーします。select 属性は、コピーするコンテンツを定義します。select 属性が結果ツリーフラグメントを識別する場合、完全なフラグメントが結果ツリーにコピーされます。select がノードセットを識別する場合、ノードセットのすべてのノードがドキュメント順に結果ツリーにコピーされます。一方、<xsl:copy> では、名前空間ノード、属性ノード、および子ノードを含めて、ノード全体がコピーされます。select 属性が結果ツリーフラグメントまたはノードセット以外のコンテンツを識別する場合、そのコンテンツは文字列に変換され、結果ツリーに挿入されます。 | |
カテゴリ | |
命令 |
|
必須の属性 | |
|
|
省略可能な属性 | |
なし。 |
|
コンテンツ | |
なし。<xsl:copy-of> は空の要素です。 |
|
指定先 | |
<xsl:copy-of> はテンプレート内に指定します。 |
|
定義先 | |
XSLT 11.3 節「Using Values of Variables and Parameters with xsl:copy-of」 |
|
例 | |
結果ツリーに入力ドキュメントをコピーする単純なスタイルシートを使用して、<xsl:copy-of> について示します。スタイルシートは次のとおりです。 <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> 次のドキュメントに対してスタイルシートをテストします。 <?xml version="1.0"?> <list> <title>A few of my favorite albums</title> <listitem>A Love Supreme</listitem> <listitem>Beat Crazy</listitem> <listitem>Here Come the Warm Jets</listitem> <listitem>Kind of Blue</listitem> <listitem>London Calling</listitem> <listitem>Remain in Light</listitem> <listitem>The Joshua Tree</listitem> <listitem>The Indestructible Beat of Soweto</listitem> </list> XML ドキュメントを変換すると、結果は入力ドキュメントに非常に似たものになります。 <?xml version="1.0" encoding="UTF-8"?> <list> <title>A few of my favorite albums</title> <listitem>A Love Supreme</listitem> <listitem>Beat Crazy</listitem> <listitem>Here Come the Warm Jets</listitem> <listitem>Kind of Blue</listitem> <listitem>London Calling</listitem> <listitem>Remain in Light</listitem> <listitem>The Joshua Tree</listitem> <listitem>The Indestructible Beat of Soweto</listitem> </list> 2 つのドキュメントの唯一の違いは、スタイルシートエンジンが encoding を XML 宣言に追加したことです。これを <xsl:copy> 要素の例と比較してください。 |