<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="expressions" page="parentheses" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Parentheses and operator precedence</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Parentheses and operator precedence"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Parentheses and operator precedence</h1>
      <p>In general an expression may be enclosed in parentheses without changing its meaning.</p>
      <p>If parentheses are not used, operator precedence follows the sequence below, starting with the
operators that bind most tightly. Within each group the operators are evaluated left-to-right</p>
      <table>
         <tr>
            <td content="para">
               <p>
               <b>Operator</b>
            </p>
            </td>
            <td content="para">
               <p>
               <b>Meaning</b>
            </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>[]</p>
            </td>
            <td content="para">
               <p>predicate</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>/, //</p>
            </td>
            <td content="para">
               <p>path operator</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>unary -, unary +</p>
            </td>
            <td content="para">
               <p>unary plus and minus</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>cast as</p>
            </td>
            <td content="para">
               <p>dynamic type conversion</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>castable as</p>
            </td>
            <td content="para">
               <p>type test</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>treat as</p>
            </td>
            <td content="para">
               <p>static type conversion</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>instance of</p>
            </td>
            <td content="para">
               <p>type test</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>except, intersect</p>
            </td>
            <td content="para">
               <p>set difference and intersection</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>|, union</p>
            </td>
            <td content="para">
               <p>union operation on sets</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>*, div, idiv, mod</p>
            </td>
            <td content="para">
               <p>multiply, divide, integer divide, modulo</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>+, -</p>
            </td>
            <td content="para">
               <p>plus, minus</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>to</p>
            </td>
            <td content="para">
               <p>range expression</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>=, !=, is, &lt;, &lt;=;, &gt;, &gt;=, eq, ne, lt, le, gt, ge</p>
            </td>
            <td content="para">
               <p>comparisons</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>and</p>
            </td>
            <td content="para">
               <p>Boolean and</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>or</p>
            </td>
            <td content="para">
               <p>Boolean or</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>if</p>
            </td>
            <td content="para">
               <p>conditional expressions</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>some, every</p>
            </td>
            <td content="para">
               <p>quantified expressions</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>for</p>
            </td>
            <td content="para">
               <p>iteration (mapping) over a sequence</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>, (comma)</p>
            </td>
            <td content="para">
               <p>Sequence concatenation</p>
            </td>
         </tr>
      </table>
      <p>The various operators are described, in roughly the above order, in the sections that follow.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="filter.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>