The xsl:comment Element: Generating Comments

The <xsl:comment> Element: Generating Comments

You can also create comments on the fly with the <xsl:comment> element. This element has no attributes and encloses a template body that sets the text of the comment.

In the following example, Im creating comments that are to replace <PLANET> elements, and Ill include the name of the planet in the text of the comment:

Listing 6.8 Using <xsl:comment>
 <?xml version="1.0"?>  <xsl:stylesheet version="1.0"  xmlns:xsl="">  <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> 

Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
Year: 2005
Pages: 196

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: