<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="changes" page="intro91" subpage="opt91"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Optimization</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: Optimization"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Optimization</h1>
      <p>The XQuery expression <code>for $x at $p in EXPR return $p</code> is now rewritten as
<code>1 to count(EXPR)</code>.</p>
      <p>A filter expression that filters a constant sequence is now evaluated at compile time, provided the predicate does not
use any variables and has no dependencies on the dynamic context other than the context item, position, and size.</p>
      <p>"Loop-lifting" (extraction of subexpressions to prevent them being repeatedly evaluated within a loop) is now
extended to XQuery <code>for</code> expressions that have a position variable.</p>
      <p>Adjacent literal text nodes in the content of an element or document constructor are now merged at compile time.
(These can arise as a result of early evaluation of expressions in the content sequence.)</p>
      <p>The <code>AttributeValidator</code>, which checks whether required attributes are present and expands default
values during schema validation, has been rewritten for efficiency, to do most of the work of setting up the necessary
data structures at schema compile time rather than on a per-element basis at validation time. It also uses two different
implementations of the main data structure to handle the typical case with a small number of attributes, and the more
difficult but unusual case where large numbers of attributes are declared.</p>
      <p>When an attribute has an enumeration type, space is saved on the instance tree by using references to the
attribute value as held in the compiled schema, avoiding holding multiple copies of the same string.</p>
      <p>In XSLT, multiple identical key definitions are now merged. These can arise when the same stylesheet module
is imported several times in different places. Previously, this led to the construction of multiple indexes, whose results
were merged at run-time.</p>
      <p>The set of XPath expressions for which streamed evaluation is possible (using <code>saxon:stream()</code> or
equivalent interfaces) has been slightly extended. It can now include expressions that return a union of elements
and attributes; previously it was required to return exclusively elements, or exclusively attributes. It now
allows multiple predicates (previously only a single predicate was allowed).</p>
      <p>In XSLT, tail-call optimization is now performed for a call on <code>xsl:call-template</code> that appears
within an <code>xsl:for-each</code> instruction, provided that it can be statically determined that the select
expression of the <code>xsl:for-each</code> returns at most one item. </p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="../s90.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>