Like this article? We recommend
Generating Comments with xsl:comment
You can also create comments on the fly with the <xsl:comment> element. Heres an example; in this case, Im creating comments that will replace <PLANET> elements, and Ill include the name of the planet in the text of the comment:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="PLANETS"> <HTML> <HEAD> <TITLE> Planets </TITLE> </HEAD> <BODY> <xsl:apply-templates select="PLANET"/> </BODY> </HTML> </xsl:template> <xsl:template match="PLANET"> <xsl:comment>This was the <xsl:value-of select="NAME"/> element</xsl:comment> </xsl:template> </xsl:stylesheet>
Heres the result:
<HTML> <HEAD> <TITLE> Planets </TITLE> </HEAD> <BODY> <!--This was the Mercury element--> <!--This was the Venus element--> <!--This was the Earth element--> </BODY> </HTML>