This attribute may be set on any instruction in the stylesheet, including a literal result element, though the recommended use is to set it on an xsl:template or xsl:function declaration. The permitted values are "yes" and "no". If the value is "yes", then at compile time Saxon outputs (to the standard error output) a representation of the optimized expression tree for the template or function containing that instruction. The tree is represented by indentation. For example, consider this source code:

 <xsl:variable name="p" select="0"/>

 <xsl:template match="/" saxon:explain="yes" xmlns:saxon="" exclude-result-prefixes="saxon">
     <xsl:when test="$p != 0"><xsl:value-of select="1 div $p"/></xsl:when>

This produces the output:

Optimized expression tree for template at line 7 in (URI):
                      name a

This indicates that the template has been reduced to an instruction to create an element with name a, whose content is a single text node holding the string "12". This is because Saxon has established at compile time that it will always take the "otherwise" branch of the xsl:choose instruction. There is no xsl:value-of instruction in the source code, but the literal text node "12" is compiled to the same code as if the user had written <xsl:value-of select="'12'"/>