Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 287

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensions" page="attributes" subpage="explain"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: saxon:explain</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: saxon:explain"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>saxon:explain</h1>
      <p>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 <code>xsl:template</code> or <code>xsl:function</code>
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:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>
 &lt;xsl:variable name="p" select="0"/&gt;

 &lt;xsl:template match="/" saxon:explain="yes" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="saxon"&gt;
   &lt;a&gt;
     &lt;xsl:choose&gt;
     &lt;xsl:when test="$p != 0"&gt;&lt;xsl:value-of select="1 div $p"/&gt;&lt;/xsl:when&gt;
     &lt;xsl:otherwise&gt;12&lt;/xsl:otherwise&gt;
     &lt;/xsl:choose&gt;
   &lt;/a&gt;
 &lt;/xsl:template&gt;</code>
         </pre>
      </div>
      <p>This produces the output:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>Optimized expression tree for template at line 8 in file:/e:/temp/test.xsl:
&lt;directElement name="a" validation="skip"&gt;
  &lt;valueOf&gt;
    &lt;literal value="12" type="xs:string"/&gt;
  &lt;/valueOf&gt;
&lt;/directElement&gt;</code>
         </pre>
      </div>
      <p>This indicates that the template has been reduced to an instruction to create an element with name <code>a</code>,
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 <code>xsl:choose</code>
instruction. There is no <code>xsl:value-of</code> instruction in the source code, but the literal
text node "12" is compiled to the same code as if the user had written 
<code>&lt;xsl:value-of select="'12'"/&gt;</code></p>
      <p>To get this output for all templates and functions in the stylesheet, you can use the <code>-explain</code>
option on the command line.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="memo-function.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>