I have an XSLT file littered with comments such as the following:
<xsl:comment>Entering shipping block</xsl:comment>
Is there a way to explicity disable these comments so that they aren't output at runtime in production? The output of the XSLT file is shown in a public API, so while it is useful for debugging, I would rather be able to switch it off.
The only way I can think of is to have a flag that is set in development mode to turn on the comments:
<xsl:if test="$enableDebug='true'">
<xsl:comment>Entering shipping block</xsl:comment>
</xsl:if>
Is there another way?
(I'm using XSLT 2.0.)
You could declare a variable
verboseat the very top of your XSL:and wrap your comments in
<xsl:if>like this:If you then want to temporarily deactivate the comments, just remove the
1from theverbosevariable: