Share via


<xsl:comment> 要素

出力内容にコメントを生成します。

<xsl:comment>
</xsl:comment>

要素情報

出現回数

無制限

親要素

xsl:copyxsl:elementxsl:fallbackxsl:for-eachxsl:ifxsl:messagexsl:otherwisexsl:paramxsl:templatexsl:variablexsl:whenxsl:with-param、出力要素

子要素

xsl:apply-importsxsl:apply-templatesxsl:call-templatexsl:choosexsl:copyxsl:copy-ofxsl:fallbackxsl:for-eachxsl:ifxsl:messagexsl:numberxsl:textxsl:value-ofxsl:variable

解説

<xsl:comment> の子によって生成されるテキストは、開始文字 (<!--) と終了文字 (-->) の間に表示されます。

使用例

次の例では、news.xsl スタイル シートによって news.xml ドキュメントを変換し、XSLT 出力にコメントを挿入します。

XML ファイル (news.xml)

<?xml version ="1.0"?>
<?xml-stylesheet type="text/xsl" href="news.xsl"?>
<news>
<story1>Here is the top news story.</story1>
    <story2> Here is the next news story.</story2>
</news>

XSLT ファイル (news.xsl)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="/">
<HTML>
<BODY>
<xsl:comment>insert top news story</xsl:comment>
<P>
<xsl:value-of select="//story1"/>
</P>
</BODY>
</HTML>
</xsl:template>

</xsl:stylesheet>

出力

これは書式付き出力です。

Here is the top news story.

これはプロセッサ出力です。

<HTML>
<BODY><!--insert top news story-->
<P>Here is the top news story.</P>
</BODY>
</HTML>