<xsl:comment> Element

<xsl:comment> Element

Generates a comment in the output.

<xsl:comment>
</xsl:comment>

The text generated by the children of <xsl:comment> appears between the starting characters (<!--) and the closing characters (-->).

In the following example, the news.xsl style sheet transforms the news.xml document, and inserts a comment into the XSLT output.

XML File (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 File (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>

Output

This is the formatted output:

Here is the top news story.

This is the processor output:

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




Build Date:

2012-08-02
Show:
© 2016 Microsoft