Another abandoned server code base... this is kind of an ancestor of taskrambler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

6210 lines
243 KiB

<?xml version="1.0" encoding="utf-8"?>
<!--XSLT Processor: SAXON 8.9.0.4 from Saxonica SAXON SA 8.9.0.4-->
<!--This document was created at 20100406 1336-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" />
<title>XQuery Scripting Extension 1.0</title>
<style type="text/css">
/*<![CDATA[*/
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
div.issue
p.title { margin-left: -2em; }
ol.enumar { list-style-type: decimal; }
ol.enumla { list-style-type: lower-alpha; }
ol.enumlr { list-style-type: lower-roman; }
ol.enumua { list-style-type: upper-alpha; }
ol.enumur { list-style-type: upper-roman; }
li p { margin-top: 0.3em;
margin-bottom: 0.3em; }
sup small { font-style: italic;
color: #8F8F8F;
}
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
div.issue { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
margin-bottom: 20pt;
}
th.issue-toc-head { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
}
table.small { font-size: x-small; }
a.judgment:visited, a.judgment:link { font-family: sans-serif;
color: black;
text-decoration: none }
a.processing:visited, a.processing:link { color: black;
text-decoration: none }
a.env:visited, a.env:link { color: black;
text-decoration: none }
/*]]>*/
</style>
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/W3C-WD.css" />
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src=
"http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width=
"72" /></a></p>
<h1><a name="title" id="title"></a>XQuery Scripting Extension
1.0</h1>
<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Working Draft 8
April 2010</h2>
<dl>
<dt>This version:</dt>
<dd><a href=
"http://www.w3.org/TR/2010/WD-xquery-sx-10-20100408">http://www.w3.org/TR/2010/WD-xquery-sx-10-20100408</a></dd>
<dt>Latest version:</dt>
<dd><a href=
"http://www.w3.org/TR/xquery-sx-10/">http://www.w3.org/TR/xquery-sx-10/</a></dd>
<dt>Previous versions:</dt>
<dd><a href=
"http://www.w3.org/TR/2008/WD-xquery-sx-10-20081203">http://www.w3.org/TR/2008/WD-xquery-sx-10-20081203</a>
<a href=
"http://www.w3.org/TR/2008/WD-xquery-sx-10-20080328/">http://www.w3.org/TR/2008/WD-xquery-sx-10-20080328/</a></dd>
<dt>Editors:</dt>
<dd><span><a href="http://snelson.org.uk/john">John
Snelson</a></span>, Oracle Corporation <a href=
"mailto:john.snelson@oracle.com">&lt;john.snelson@oracle.com&gt;</a></dd>
<dd>Don Chamberlin, IBM Almaden Research Center, via <a href=
"http://www.almaden.ibm.com/cs/people/chamberlin/">http://www.almaden.ibm.com/cs/people/chamberlin/</a></dd>
<dd>Daniel Engovatov, W3C invited expert</dd>
<dd>Dana Florescu, Oracle Corporation <a href=
"mailto:dana.florescu@oracle.com">&lt;dana.florescu@oracle.com&gt;</a></dd>
<dd>Giorgio Ghelli, University of Pisa <a href=
"mailto:ghelli@di.unipi.it">&lt;ghelli@di.unipi.it&gt;</a></dd>
<dd>Jim Melton, Oracle Corporation <a href=
"mailto:jim.melton@acm.org">&lt;jim.melton@acm.org&gt;</a></dd>
<dd>Jérôme Siméon, IBM T.J. Watson Research Center <a href=
"mailto:simeon@us.ibm.com">&lt;simeon@us.ibm.com&gt;</a></dd>
</dl>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>&#160;©&#160;2010&#160;<a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.eu/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href=
"http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
</div>
<hr />
<div>
<h2><a name="abstract" id="abstract"></a>Abstract</h2>
<p>This specification defines an extension to <a href=
"#XQ10">[XQuery 1.0]</a> and <a href="#XQueryUpdate">[XQuery Update
Facility]</a>. Expressions can be evaluated in a specific order,
with later expressions seeing the effects of the expressions that
came before them. This specification introduces several new kinds
of expression, including the apply, assignment, while, and exit
expression, and a block expression with local variable
declarations.</p>
</div>
<div>
<h2><a name="status" id="status"></a>Status of this Document</h2>
<p><em>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest
revision of this technical report can be found in the <a href=
"http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This is a <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html#maturity-levels">
Working Draft</a> as described in the <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html">Process
Document</a>. It has been developed by the W3C <a href=
"http://www.w3.org/XML/Query/">XML Query Working Group</a>, which
is part of the <a href="http://www.w3.org/XML/Activity">XML
Activity</a>. The Working Group expects to advance this
specification to <a href=
"http://www.w3.org/2005/10/Process-20051014/tr.html#RecsW3C">Recommendation</a>
Status.</p>
<p>This is the last version of XQuery Scripting Extension that is
aligned with XQuery Update Facility 1.0. In future versions of this
document, the Working Group intends to reposition XQuery Scripting
Extension 1.0 against the <a href="#XQ11">[XQuery 1.1]</a> set of
specifications, and remove it from the <a href="#XQ10">[XQuery
1.0]</a> publication track.</p>
<p>No implementation report currently exists. However, a Test Suite
for XQuery Scripting Extension 1.0 is under development.</p>
<p>This document incorporates changes made against the previous
publication of the Working Draft of 3 December 2008. Changes to
this document since the previous publication of the Working Draft
are detailed in <a href="#id-revisions-log"><b>[G Revision
Log]</b></a>.</p>
<p>Please report errors in this document using W3C's <a href=
"http://www.w3.org/Bugs/Public/">public Bugzilla system</a>
(instructions can be found at <a href=
"http://www.w3.org/XML/2005/04/qt-bugzilla">http://www.w3.org/XML/2005/04/qt-bugzilla</a>).
If access to that system is not feasible, you may send your
comments to the W3C XSLT/XPath/XQuery public comments mailing list,
<a href=
"mailto:public-qt-comments@w3.org">public-qt-comments@w3.org</a>.
It will be very helpful if you include the string “[SX]” in the
subject line of your report, whether made in Bugzilla or in email.
Please use multiple Bugzilla entries (or, if necessary, multiple
email messages) if you have more than one comment to make. Archives
of the comments and responses are available at <a href=
"http://lists.w3.org/Archives/Public/public-qt-comments/">http://lists.w3.org/Archives/Public/public-qt-comments/</a>.</p>
<p>Publication as a Working Draft does not imply endorsement by the
W3C Membership. This is a draft document and may be updated,
replaced or obsoleted by other documents at any time. It is
inappropriate to cite this document as other than work in
progress.</p>
<p>This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
February 2004 W3C Patent Policy</a>. W3C maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/18797/status#disclosures">public
list of any patent disclosures</a> made in connection with the
deliverables of the group; that page also includes instructions for
disclosing a patent. An individual who has actual knowledge of a
patent which the individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">
Essential Claim(s)</a> must disclose the information in accordance
with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">
section 6 of the W3C Patent Policy</a>.</p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#Introduction">Introduction</a><br />
2 <a href="#id-extensions-to-processing-model">Extensions to the
Processing Model</a><br />
&#160;&#160;&#160;&#160;2.1 <a href=
"#id-evaluation-order">Evaluation Order</a><br />
&#160;&#160;&#160;&#160;2.2 <a href="#id-snapshot-scope">Snapshot
and Execution Scope</a><br />
&#160;&#160;&#160;&#160;2.3 <a href=
"#id-variable-revalidation">Variable Binding Revalidation</a><br />
&#160;&#160;&#160;&#160;2.4 <a href=
"#id-updating-constraint">Updating Expression Constraints</a><br />
&#160;&#160;&#160;&#160;2.5 <a href="#id-sequential">Sequential
Expressions</a><br />
3 <a href="#id-extensions-to-static-context">Extensions to the
Static Context</a><br />
&#160;&#160;&#160;&#160;3.1 <a href="#id-namespace">Predefined
Namespace</a><br />
&#160;&#160;&#160;&#160;3.2 <a href="#id-query-mode">Query
Mode</a><br />
4 <a href="#id-extensions-to-prolog">Extensions to the
Prolog</a><br />
&#160;&#160;&#160;&#160;4.1 <a href=
"#id-assignable-global-var">Assignable Global Variables</a><br />
&#160;&#160;&#160;&#160;4.2 <a href="#id-function-decl">Function
Declarations</a><br />
&#160;&#160;&#160;&#160;4.3 <a href="#id-query-mode-option">Query
Mode Option</a><br />
5 <a href="#id-new-exprs">New Kinds of Expressions</a><br />
&#160;&#160;&#160;&#160;5.1 <a href="#id-apply">Apply
Expression</a><br />
&#160;&#160;&#160;&#160;5.2 <a href="#id-block">Block
Expressions</a><br />
&#160;&#160;&#160;&#160;5.3 <a href="#id-assignment">Assignment
Expression</a><br />
&#160;&#160;&#160;&#160;5.4 <a href="#id-while">While
Expression</a><br />
&#160;&#160;&#160;&#160;5.5 <a href="#id-exit">Exit
Expression</a><br />
&#160;&#160;&#160;&#160;5.6 <a href="#id-query-mode-pragma">Query
Mode Pragma</a><br />
6 <a href="#id-existing-exprs">Changes to Existing
Expressions</a><br />
&#160;&#160;&#160;&#160;6.1 <a href=
"#id-parenthesized-expr">Parentheses</a><br />
&#160;&#160;&#160;&#160;6.2 <a href="#id-function-call">Function
Calls</a><br />
&#160;&#160;&#160;&#160;6.3 <a href="#id-path-expr">Path
Expressions</a><br />
&#160;&#160;&#160;&#160;6.4 <a href=
"#id-predicate">Predicates</a><br />
&#160;&#160;&#160;&#160;6.5 <a href="#id-concat-expr">Concatenation
Expressions</a><br />
&#160;&#160;&#160;&#160;6.6 <a href="#id-node-constructors">Direct
and Computed Node Constructors</a><br />
&#160;&#160;&#160;&#160;6.7 <a href="#id-FLWOR-expr">FLWOR
Expressions</a><br />
&#160;&#160;&#160;&#160;6.8 <a href=
"#id-conditional-expr">Conditional Expressions</a><br />
&#160;&#160;&#160;&#160;6.9 <a href=
"#id-quantified-expr">Quantified Expressions</a><br />
&#160;&#160;&#160;&#160;6.10 <a href=
"#id-typeswitch-expr">Typeswitch Expressions</a><br />
&#160;&#160;&#160;&#160;6.11 <a href="#id-update-expr">Insert,
Delete, Replace, and Rename Expressions</a><br />
&#160;&#160;&#160;&#160;6.12 <a href="#id-transform-expr">Transform
Expressions</a><br />
&#160;&#160;&#160;&#160;6.13 <a href="#id-other-expr">Other
Expressions</a><br />
7 <a href="#id-example">Example</a><br /></p>
<h3><a name="appendices" id="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#id-grammar">EBNF for XQuery 1.0 Grammar
with Scripting Extensions</a><br />
&#160;&#160;&#160;&#160;A.1 <a href="#id-terminal-symbols">Terminal
Symbols</a><br />
&#160;&#160;&#160;&#160;A.2 <a href=
"#id-extra-grammatical-constraints">Extra-grammatical
Constraints</a><br />
B <a href="#id-xqsx-xqueryx">XML Syntax (XQueryX) for XQuery
Scripting Extension 1.0</a><br />
&#160;&#160;&#160;&#160;B.1 <a href=
"#id-xqsx-xqueryx-schema">Schema</a><br />
&#160;&#160;&#160;&#160;B.2 <a href=
"#id-xqsx-xqueryx-stylesheet">Stylesheet</a><br />
&#160;&#160;&#160;&#160;B.3 <a href=
"#id-xqsx-xqueryx-examples">Example</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;B.3.1 <a href=
"#id-xqsx-xqueryx-xq-rep">XQuery Representation</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;B.3.2 <a href=
"#id-xqsx-xqueryx-xqx-rep">XQueryX Representation</a><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;B.3.3 <a href=
"#id-xqsx-xqueryx-transformed-rep">Transformed XQuery
Representation</a><br />
C <a href="#id-implementation-defined-items">Implementation-Defined
Items</a><br />
D <a href="#id-references">References</a><br />
E <a href="#id-errors">Error Conditions</a><br />
&#160;&#160;&#160;&#160;E.1 <a href="#id-new-error-codes">New Error
Codes</a><br />
&#160;&#160;&#160;&#160;E.2 <a href=
"#id-amended-error-codes">Amendments to Existing Error
Codes</a><br />
F <a href="#id-glossary">Glossary</a> (Non-Normative)<br />
G <a href="#id-revisions-log">Revision Log</a>
(Non-Normative)<br />
&#160;&#160;&#160;&#160;G.1 <a href="#id-log-20081203">Since the 3
December 2008 Working Draft</a><br />
&#160;&#160;&#160;&#160;G.2 <a href="#id-log-20080328">Since the 28
March 2008 Working Draft</a><br /></p>
</div>
<hr />
<div class="body">
<div class="div1">
<h2><a name="Introduction" id="Introduction"></a>1
Introduction</h2>
<p>XQuery Scripting Extension extends <a href="#XQ10">[XQuery
1.0]</a>, enabling it to serve as a scripting language in order to
satisfy <a href="#ScriptingRequirements">[XQuery Scripting
Requirements]</a>. A prerequisite for this extension is <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>. The following
abbreviations are used in this specification: [<a name="dt-xquf"
id="dt-xquf" title="XQUF">Definition</a>: <b>XQUF</b> is an
abbreviation for <a href="#XQueryUpdate">[XQuery Update
Facility]</a>.] [<a name="dt-xqsx" id="dt-xqsx" title=
"XQSX">Definition</a>: <b>XQSX</b> is an abbreviation for XQuery
Scripting Extension.]</p>
<p>In this document, examples and material labeled as "Note" are
provided for explanatory purposes and are not normative.</p>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> has the following
properties:</p>
<ul>
<li>
<p>It is a strict superset of <a title="XQUF" href=
"#dt-xquf">XQUF</a>, in the sense that all valid <a title="XQUF"
href="#dt-xquf">XQUF</a> expressions are also valid <a title="XQSX"
href="#dt-xqsx">XQSX</a> expressions and have the same meaning. (In
the same sense, <a title="XQUF" href="#dt-xquf">XQUF</a> is a
strict superset of <a href="#XQ10">[XQuery 1.0]</a>.)</p>
</li>
<li>
<p>It does not introduce any "modes" that affect the semantics of
expressions.</p>
</li>
<li>
<p>As in <a title="XQUF" href="#dt-xquf">XQUF</a>, the result of an
expression consists of an <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and a <a title=
"pending update list" href="#dt-pul">pending update list</a>.
[<a name="dt-xdm-instance" id="dt-xdm-instance" title=
"XDM instance">Definition</a>: An <b>XDM instance</b> is an
unconstrained sequence of zero or more nodes and/or atomic values,
as defined in <a href="#XDM">[XQuery Data Model]</a>.] [<a name=
"dt-pul" id="dt-pul" title="pending update list">Definition</a>: A
<b>pending update list</b> is an unordered collection of update
primitives, representing node state changes that have not yet been
applied, as defined in <a href="#XQueryUpdate">[XQuery Update
Facility]</a>.]</p>
</li>
</ul>
</div>
<div class="div1">
<h2><a name="id-extensions-to-processing-model" id=
"id-extensions-to-processing-model"></a>2 Extensions to the
Processing Model</h2>
<p>Expressions in XQSX may have side-effects that are visible to
subsequent expressions (according to their <a title=
"evaluation order" href="#dt-eval-order">evaluation order</a>).
This requires a number of extensions to the <a href="#XQ10">[XQuery
1.0]</a>and <a href="#XQueryUpdate">[XQuery Update Facility]</a>
processing model.</p>
<div class="div2">
<h3><a name="id-evaluation-order" id="id-evaluation-order"></a>2.1
Evaluation Order</h3>
<p>[<a name="dt-eval-order" id="dt-eval-order" title=
"evaluation order">Definition</a>: <a title="XQSX" href=
"#dt-xqsx">XQSX</a> defines an <b>evaluation order</b> on many
kinds of XQuery expressions, which is the order that operand
expressions must be evaluated in order to determine what
side-effects are visible to later expressions.] An implementation
may use any execution strategy as long as the result complies with
the semantics of this ordering.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Since none of the XQuery expressions existing before <a title=
"XQSX" href="#dt-xqsx">XQSX</a> has any immediate side-effects, no
ordering is effectively imposed on the evaluation of any expression
unless it contains one of the new <span>sequential</span>
expressions introduced by <a title="XQSX" href=
"#dt-xqsx">XQSX</a>.</p>
</div>
</div>
<div class="div2">
<h3><a name="id-snapshot-scope" id="id-snapshot-scope"></a>2.2
Snapshot <span>and Execution</span> Scope</h3>
<p>The term <b>snapshot</b> is defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> as follows: [<a name=
"dt-snapshot" id="dt-snapshot" title="snapshot">Definition</a>: A
<b>snapshot</b> is a scope within which expressions are evaluated
with respect to a fixed <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and updates are held pending.]
A snapshot is terminated by invocation of the
<code>upd:applyUpdates</code> operation. Unlike <a title="XQUF"
href="#dt-xquf">XQUF</a>, <a title="XQSX" href="#dt-xqsx">XQSX</a>
permits a query to contain more than one snapshot.</p>
<p><a href="#FO">[XQuery 1.0 and XPath 2.0 Functions and
Operators]</a> defines certain functions as <a href=
"http://www.w3.org/TR/xpath-functions/#stable">stable</a><sup><small>FO</small></sup>.
Stable functions such as <code>fn:current-time</code> and
<code>fn:doc</code> are defined to return the same result given the
same arguments within an <a href=
"http://www.w3.org/TR/xpath-functions/#execution-scope">execution
scope</a><sup><small>FO</small></sup>. <a title="XQSX" href=
"#dt-xqsx">XQSX</a> redefines the extent of an execution scope, so
that a top level query can contain many execution scopes.</p>
<p>In XQSX, each of the following expressions is <span>both</span>
a snapshot <span>and execution scope</span>:</p>
<ul>
<li>
<p>each ConcatExpr within an ApplyExpr</p>
</li>
<li>
<p>each initialization expression in a BlockVarDecl</p>
</li>
<li>
<p>the expression on the right-hand side of an AssignmentExpr</p>
</li>
<li>
<p>the expression in an ExitExpr</p>
</li>
<li>
<p>the test expression in a WhileExpr</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-variable-revalidation" id=
"id-variable-revalidation"></a>2.3 Variable Binding
Revalidation</h3>
<p>To ensure type soundness, variable bindings are revalidated at
the end of each scope to check that any updates applied have not
made them invalid with repect to their declared types. It is a
dynamic error [<a href="#ERRSXDY0003" title=
"err:SXDY0003">err:SXDY0003</a>] if, after applying a pending
update list (using <code>upd:applyUpdates</code>), the XDM instance
bound to any in-scope variable does not match the static type of
that variable according to SequenceType matching rules.</p>
</div>
<div class="div2">
<h3><a name="id-updating-constraint" id=
"id-updating-constraint"></a>2.4 Updating Expression
Constraints</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> relaxes the constraints
on the placement of <a title="updating expression" href=
"#dt-updating-expr">updating expressions</a>, so that a non-empty
<a title="XDM instance" href="#dt-xdm-instance">XDM instance</a>
can be returned by an expression as well as a non-empty <a title=
"pending update list" href="#dt-pul">pending update list</a>. In
order to allow this, new rules to determine the category and
resulting <a title="pending update list" href="#dt-pul">pending
update list</a> are added to every existing expression, following
certain principles:</p>
<ul>
<li>
<p>An <a title="updating expression" href=
"#dt-updating-expr">updating expression</a> is allowed anywhere a
<a title="simple expression" href="#dt-simple-expr">simple
expression</a> is allowed. If an operand of an expression is an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a>, the expression itself is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>An expression may not be both <a title="sequential expression"
href="#dt-sequential-expr">sequential</a> and <a title=
"updating expression" href="#dt-updating-expr">updating</a>. If an
<a title="updating expression" href=
"#dt-updating-expr">updating</a> expression contains or uses a
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a> (or vice versa), an
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>].</p>
</li>
<li>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> that results from any given expression is the result of
calling <code>upd:mergeUpdates</code> on the <a title=
"pending update list" href="#dt-pul">pending update lists</a> from
the result of all of its operand expressions. No <a title=
"pending update list" href="#dt-pul">pending update list</a> is
ever discarded.</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-sequential" id="id-sequential"></a>2.5 Sequential
Expressions</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> introduces a new
expression category called <a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a>. The simple and
updating expression categories introduced by <a title="XQUF" href=
"#dt-xquf">XQUF</a> are retained, but the vacuous expression
category no longer has significance. Informal definitions of all
the expression categories are summarized here. For normative
definitions of the categories, see the "Category Rules" that are
specified for each kind of expression in <a href=
"#id-new-exprs"><b>[5 New Kinds of Expressions]</b></a> and
<a href="#id-existing-exprs"><b>[6 Changes to Existing
Expressions]</b></a>.</p>
<ol class="enumar">
<li>
<p>[<a name="dt-updating-expr" id="dt-updating-expr" title=
"updating expression">Definition</a>: An <b>updating expression</b>
is an expression that can return a non-empty <a title=
"pending update list" href="#dt-pul">pending update list</a>.]
Updating expressions include insert, delete, replace, rename, and
calls to updating functions, as well as certain other expressions
that contain nested updating expressions. An updating expression
may return a non-empty <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> as well as a non-empty
<a title="pending update list" href="#dt-pul">pending update
list</a> - however note that it does not actually apply any
updates.</p>
</li>
<li>
<p>[<a name="dt-sequential-expr" id="dt-sequential-expr" title=
"sequential expression">Definition</a>: A <b>sequential
expression</b> is an expression that can have side effects other
than constructing a new node or raising an error.] Side effects
include applying updates to an <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a>, altering the dynamic context,
or affecting the flow of control. Sequential expressions include
apply expressions, assignment, exit, while, and calls to sequential
functions, as well as certain other expressions that contain nested
sequential expressions. The side effects of a sequential expression
are immediately effective and are visible to subsequent
expressions. Because of their side effects, sequential expressions
must be evaluated in a well-defined order. In addition to its side
effects, a sequential expression may return a non-empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>, but it
never returns a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a>.</p>
</li>
<li>
<p>[<a name="dt-simple-expr" id="dt-simple-expr" title=
"simple expression">Definition</a>: A <b>simple expression</b> is
an expression that is neither an <a title="updating expression"
href="#dt-updating-expr">updating expression</a> nor a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.] A simple expression may return an <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>, and it may
construct a node or raise an error.</p>
</li>
</ol>
<p>The classification of each expression into one of the above
categories is performed by static analysis. For each kind of
expression, <a title="XQSX" href="#dt-xqsx">XQSX</a> provides rules
that specify the required categories of the operand expressions and
the category of the expression itself.</p>
<p>Note that <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a>, <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>, and <a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a> are disjoint
categories. The kinds of values that can be returned by the various
expression categories are summarized in the following table:</p>
<table border="1">
<tbody>
<tr>
<th align="center"><em>Expression category</em></th>
<th align="center"><em>Can return non-empty XDM instance?</em></th>
<th align="center"><em>Can return non-empty PUL?</em></th>
<th align="center"><em>Can have immediate side-effects?</em></th>
</tr>
<tr>
<td align="center">Simple</td>
<td align="center">YES</td>
<td align="center">NO</td>
<td align="center">NO</td>
</tr>
<tr>
<td align="center">Updating</td>
<td align="center">YES</td>
<td align="center">YES</td>
<td align="center">NO</td>
</tr>
<tr>
<td align="center">Sequential</td>
<td align="center">YES</td>
<td align="center">NO</td>
<td align="center">YES</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="div1">
<h2><a name="id-extensions-to-static-context" id=
"id-extensions-to-static-context"></a>3 Extensions to the Static
Context</h2>
<div class="div2">
<h3><a name="id-namespace" id="id-namespace"></a>3.1 Predefined
Namespace</h3>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> adds the pair
(<code>xqsx</code>,
<code>http://www.w3.org/2008/xquery-sx-10</code>) as a predefined
namespace to the statically known namespaces.</p>
</div>
<div class="div2">
<h3><a name="id-query-mode" id="id-query-mode"></a>3.2 Query
Mode</h3>
<p>[<a name="dt-query-mode" id="dt-query-mode" title=
"query mode">Definition</a>: The <b>query mode</b> governs the
composability of <a title="updating expression" href=
"#dt-updating-expr">updating</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>. Valid values are <code>sequential</code> and
<code>simple</code>.] The default initial value of query mode is
<code>sequential</code>, but it can be overwritten by an
implementation. Query mode has a lexical scope, and can be modified
at both the module and expression level.</p>
<p>In particular, query mode affects the category rules for
<a href="#id-path-expr"><b>[6.3 Path Expressions]</b></a>, <a href=
"#id-predicate"><b>[6.4 Predicates]</b></a>, <a href=
"#id-FLWOR-expr"><b>[6.7 FLWOR Expressions]</b></a>, and <a href=
"#id-quantified-expr"><b>[6.9 Quantified Expressions]</b></a>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-extensions-to-prolog" id=
"id-extensions-to-prolog"></a>4 Extensions to the Prolog</h2>
<div class="div2">
<h3><a name="id-assignable-global-var" id=
"id-assignable-global-var"></a>4.1 Assignable Global Variables</h3>
<h5><a name="d7e707" id="d7e707"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-VarDecl" id=
"doc-xquery-VarDecl"></a>[<small>24</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-VarDecl"></a><a href=
"#prod-xquery-VarDecl">VarDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" ("unassignable"? | "assignable") "variable" "$"
<a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ((":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>) | "external")</code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> allows the qualifiers
<code>assignable</code> and <code>unassignable</code> to be used in
a Prolog variable declaration. [<a name="dt-assignable" id=
"dt-assignable" title="assignable">Definition</a>: Prolog variables
declared as <b>assignable</b> may have their value changed by an
<a href="#id-assignment"><b>[5.3 Assignment Expression]</b></a>.]
If an assignment qualifier is not used, the default is
<code>unassignable</code>.</p>
<p>The semantics of assignable variables are the same as the
semantics of unassignable variables, except that the static type of
an assignable variable without a declared type is always
<code>item()*</code>.</p>
<p>The initializing expression of a prolog variable (whether
assignable or not) must be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> [<a href="#ERRXUST0001"
title="err:XUST0001">err:XUST0001</a>].</p>
</div>
<div class="div2">
<h3><a name="id-function-decl" id="id-function-decl"></a>4.2
Function Declarations</h3>
<h5><a name="d7e784" id="d7e784"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FunctionDecl" id=
"doc-xquery-FunctionDecl"></a>[<small>26</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FunctionDecl"></a><a href=
"#prod-xquery-FunctionDecl">FunctionDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("declare" ("simple"? | "updating") "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a> | "external"))<br />
| ("declare" "sequential" "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#doc-xquery-Block">Block</a> | "external"))</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Definitions:</dt>
<dd>
<p>[<a name="dt-simple-function" id="dt-simple-function" title=
"simple function">Definition</a>: A <b>simple function</b> is a
function whose declaration specifies neither <code>updating</code>
nor <code>sequential</code>. A <a title="simple function" href=
"#dt-simple-function">simple function</a> may optionally specify
the keyword <code>simple</code>.]</p>
<p>[<a name="dt-updating-function" id="dt-updating-function" title=
"updating function">Definition</a>: An <b>updating function</b> is
a function whose declaration specifies the keyword
<code>updating</code>.]</p>
<p>[<a name="dt-sequential-function" id="dt-sequential-function"
title="sequential function">Definition</a>: A <b>sequential
function</b> is a function whose declaration specifies the keyword
<code>sequential</code>.]</p>
</dd>
<dt class="label">Category Rules:</dt>
<dd>
<ul>
<li>
<p>If the body of a <a title="simple function" href=
"#dt-simple-function">simple function</a> is an EnclosedExpr, it
must be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a>.</p>
</li>
<li>
<p>If the body of an <a title="updating function" href=
"#dt-updating-function">updating function</a> is an EnclosedExpr,
it must be either an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expression</a>.</p>
</li>
<li>
<p>If the body of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is a Block it
must be either a <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
<li>
<p>If the body of a function violates the category rules for it's
declared category, [<a href="#ERRSXST0008" title=
"err:SXST0008">err:SXST0008</a>] is raised.</p>
</li>
</ul>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The semantics of <a title="simple function" href=
"#dt-simple-function">simple functions</a> are defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> and <a href=
"#XQ10">[XQuery 1.0]</a>, and remain unchanged in <a title="XQSX"
href="#dt-xqsx">XQSX</a>.</p>
<p>The semantics of <a title="updating function" href=
"#dt-updating-function">updating functions</a> as originally
defined in <a href="#XQueryUpdate">[XQuery Update Facility]</a> are
extended as follows:</p>
<ul>
<li>
<p>A return type is permitted.</p>
</li>
<li>
<p>If <code>external</code> is specified, the external function may
return both a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a> and a non-empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a>.</p>
</li>
<li>
<p>If the result of an <a title="updating function" href=
"#dt-updating-function">updating function</a> does not match its
declared result type (after applying function conversion rules as
specified in <a href=
"http://www.w3.org/TR/xquery#id-function-calls">Section 3.1.5
Function Calls</a><sup><small>XQ</small></sup>), a type error is
raised [<a href="http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. The
default result type of an <a title="updating function" href=
"#dt-updating-function">updating function</a> is
<code>item()*</code>.</p>
</li>
</ul>
<p>The semantics of <a title="sequential function" href=
"#dt-sequential-function">sequential functions</a> are as
follows:</p>
<ul>
<li>
<p>The result of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is determined by
the first <a href="#id-exit"><b>[5.5 Exit Expression]</b></a>
encountered during evaluation of the Block. If no exit expression
is encountered, the result of the function is the value returned by
the Block that comprises its body.</p>
</li>
<li>
<p>If the result of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> does not match
its declared result type (after applying function conversion rules
as specified in <a href=
"http://www.w3.org/TR/xquery#id-function-calls">Section 3.1.5
Function Calls</a><sup><small>XQ</small></sup>), a type error is
raised [<a href="http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. The
default result type of a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is
<code>item()*</code>.</p>
</li>
<li>
<p>If a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a> is declared
<code>external</code>, its implementation is outside the XQuery
environment. The means by which parameters are passed to an
external function and its result is returned to the calling
expression are implementation-defined. An external sequential
function may not return a non-empty <a title="pending update list"
href="#dt-pul">pending update list</a> [<a href="#ERRSXDY0004"
title="err:SXDY0004">err:SXDY0004</a>].</p>
</li>
</ul>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-query-mode-option" id=
"id-query-mode-option"></a>4.3 Query Mode Option</h3>
<h5><a name="d7e1014" id="d7e1014"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OptionDecl" id=
"doc-xquery-OptionDecl"></a>[<small>13</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OptionDecl"></a><a href=
"#prod-xquery-OptionDecl">OptionDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "option" <a href="#prod-xquery-QName">QName</a>
<a href="#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines the QName
<code>xqsx:query-mode</code> as a well-known option name for use in
an OptionDecl, which sets the <a title="query mode" href=
"#dt-query-mode">query mode</a> in the static context for the
module to the value specified. A static error is raised [<a href=
"#ERRSXST0009" title="err:SXST0009">err:SXST0009</a>] if the value
for a <code>xqsx:query-mode</code> option is not either
<code>sequential</code> or <code>simple</code>.</p>
<p>Implementations of <a title="XQSX" href="#dt-xqsx">XQSX</a> must
recognize the option namespace URI
<code>http://www.w3.org/2008/xquery-sx-10</code>, and the option
<code>xqsx:query-mode</code>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-new-exprs" id="id-new-exprs"></a>5 New Kinds of
Expressions</h2>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> extends the XQuery 1.0
syntax by adding several new kinds of expressions. The effect of
these new expressions on the XQuery grammar is as follows:</p>
<h5><a name="d7e1067" id="d7e1067"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1015.doc-xquery-Expr" id=
"noid_d4e1015.doc-xquery-Expr"></a>[<small>31</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ApplyExpr">ApplyExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1016.doc-xquery-ApplyExpr" id=
"noid_d4e1016.doc-xquery-ApplyExpr"></a>[<small>32</small>]&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#doc-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1017.doc-xquery-ConcatExpr" id=
"noid_d4e1017.doc-xquery-ConcatExpr"></a>[<small>33</small>]&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="noid_d4e1018.doc-xquery-ExprSingle" id=
"noid_d4e1018.doc-xquery-ExprSingle"></a>[<small>34</small>]&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-FLWORExpr">FLWORExpr</a><br />
| <a href="#doc-xquery-QuantifiedExpr">QuantifiedExpr</a><br />
| <a href="#doc-xquery-TypeswitchExpr">TypeswitchExpr</a><br />
| <a href="#doc-xquery-IfExpr">IfExpr</a><br />
| <a href="#doc-xquery-InsertExpr">InsertExpr</a><br />
| <a href="#doc-xquery-DeleteExpr">DeleteExpr</a><br />
| <a href="#doc-xquery-RenameExpr">RenameExpr</a><br />
| <a href="#doc-xquery-ReplaceExpr">ReplaceExpr</a><br />
| <a href="#doc-xquery-TransformExpr">TransformExpr</a><br />
| <a href="#doc-xquery-BlockExpr">BlockExpr</a><br />
| <a href="#doc-xquery-AssignmentExpr">AssignmentExpr</a><br />
| <a href="#doc-xquery-ExitExpr">ExitExpr</a><br />
| <a href="#doc-xquery-WhileExpr">WhileExpr</a><br />
| <a href="#prod-xquery-OrExpr">OrExpr</a></code></td>
</tr>
</tbody>
</table>
<div class="div2">
<h3><a name="id-apply" id="id-apply"></a>5.1 Apply Expression</h3>
<h5><a name="d7e1159" id="d7e1159"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ApplyExpr" id=
"doc-xquery-ApplyExpr"></a>[<small>32</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ApplyExpr"></a><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#doc-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-apply-expr" id="dt-apply-expr" title=
"apply expression">Definition</a>: An <b>apply expression</b> is a
list of semicolon-terminated ConcatExpr productions, called operand
expressions. An ApplyExpr consisting of a single ConcatExpr with no
semicolon is not an apply expression.] An apply expression is a
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
<p>The operands of the apply expression may be an expression of any
category.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The operand expressions <span>of an <a title="apply expression"
href="#dt-apply-expr">apply expression</a></span> are evaluated in
the order they appear. After the evaluation of each operand
expression, the <a title="pending update list" href=
"#dt-pul">pending update list</a> returned by the expression is
applied (by <code>upd:applyUpdates</code>). The <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> returned by
all expressions other than the last one is discarded. The side
effects of each expression are visible during the evaluation of
subsequent expressions.</p>
<p>The result of the apply expression is the <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> returned by
the last operand expression, and an empty <a title=
"pending update list" href="#dt-pul">pending update list</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-block" id="id-block"></a>5.2 Block Expressions</h3>
<h5><a name="d7e1227" id="d7e1227"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockExpr" id=
"doc-xquery-BlockExpr"></a>[<small>153</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-BlockExpr"></a><a href=
"#prod-xquery-BlockExpr">BlockExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"block" <a href="#doc-xquery-Block">Block</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Block" id=
"doc-xquery-Block"></a>[<small>154</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Block"></a><a href=
"#prod-xquery-Block">Block</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"{" <a href="#doc-xquery-BlockDecls">BlockDecls</a>
<a href="#doc-xquery-BlockBody">BlockBody</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockDecls" id=
"doc-xquery-BlockDecls"></a>[<small>155</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-BlockDecls"></a><a href=
"#prod-xquery-BlockDecls">BlockDecls</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#doc-xquery-BlockVarDecl">BlockVarDecl</a>
";")*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockVarDecl" id=
"doc-xquery-BlockVarDecl"></a>[<small>156</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-BlockVarDecl"></a><a href=
"#prod-xquery-BlockVarDecl">BlockVarDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)? ("," "$"
<a href="#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-BlockBody" id=
"doc-xquery-BlockBody"></a>[<small>157</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-BlockBody"></a><a href=
"#prod-xquery-BlockBody">BlockBody</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-initializing-expr" id="dt-initializing-expr" title=
"initializing expression">Definition</a>: The expression on the
right-hand side of a block variable declaration is called an
<b>initializing expression</b>.] <a title="initializing expression"
href="#dt-initializing-expr">Initializing expressions</a> may be in
any category.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Block variable declarations, unlike Prolog variable
declarations, permit their <a title="initializing expression" href=
"#dt-initializing-expr">initializing expressions</a> to be
<a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</p>
</div>
<p>If a BlockExpr contains <a title="initializing expression" href=
"#dt-initializing-expr">initializing expressions</a> that are
either <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, then the BlockExpr is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>. In this case the BlockBody must be either a
<a title="simple expression" href="#dt-simple-expr">simple</a> or
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, otherwise a static
error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised.</p>
<p>If a BlockExpr only contains <a title="initializing expression"
href="#dt-initializing-expr">initializing expressions</a> that are
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a> (or contains no initializing expressions), then the
BlockBody may be an expression of any category. In this case the
BlockExpr has the same category as the BlockBody.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>A block consists of zero or more block variable declarations
followed by a body. Each block variable declaration defines a
modifiable local variable whose scope is the remainder of the block
(not including its <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a>). The variable
defined in a block variable declaration occludes (hides) any
variable of the same name that is in scope at the location where
the block appears.</p>
<p>It is a static error [<a href="#ERRSXST0005" title=
"err:SXST0005">err:SXST0005</a>] if two or more variables declared
in the same block have the same expanded QName.</p>
<p>The type of each declared variable is added to <em>in-scope
variables</em> in the <em>static context</em>. <span>If no explicit
type is declared, the type of the variable is
<code>item()*</code>.</span> If a variable has both an explicit
type declaration and an <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a>, the value of
the <a title="initializing expression" href=
"#dt-initializing-expr">initializing expression</a> must match the
declared type according to SequenceType matching rules; otherwise a
type error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>.</p>
<p>The block variable declarations are evaluated in the order
written. The block variable declaration evaluates its <a title=
"initializing expression" href="#dt-initializing-expr">initializing
expression</a> and adds the resulting <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> to the <em>variable values</em>
in the <em>dynamic context</em>. Any <a title="pending update list"
href="#dt-pul">pending update list</a> returned is applied using
<code>upd:applyUpdates</code>. If no <a title=
"initializing expression" href="#dt-initializing-expr">initializing
expression</a> is present, the variable has no initial value. A
reference to a variable, other than on the left-hand side of an
assignment expression, is an error if the variable has no value in
<em>variable values</em> when the reference is evaluated [<a href=
"#ERRSXTY0006" title="err:SXTY0006">err:SXTY0006</a>].</p>
<p>After all the block variable declarations have been evaluated,
the BlockBody expression is evaluated. The result of the block
expression is the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and <a title=
"pending update list" href="#dt-pul">pending update list</a>
returned by the BlockBody.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-assignment" id="id-assignment"></a>5.3 Assignment
Expression</h3>
<h5><a name="d7e1429" id="d7e1429"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-AssignmentExpr" id=
"doc-xquery-AssignmentExpr"></a>[<small>158</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AssignmentExpr"></a><a href=
"#prod-xquery-AssignmentExpr">AssignmentExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"$" <a href="#prod-xquery-VarName">VarName</a> ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>An assignment expression is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The variable on the left-hand side of the assignment must have
been declared in one of the following ways, otherwise a static
error [<a href="#ERRSXST0007" title=
"err:SXST0007">err:SXST0007</a>] is raised:</p>
<ul>
<li>
<p>By a block variable declaration</p>
</li>
<li>
<p>As a parameter to a sequential function</p>
</li>
<li>
<p>By a variable declaration in the Prolog <span>declared as
<a title="assignable" href=
"#dt-assignable">assignable</a></span></p>
</li>
</ul>
<p>In all cases the variable must be in the in-scope variables,
otherwise a static error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPST0008" title=
"err:XPST0008">err:XPST0008</a>]<sup><small>XQ</small></sup>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>Variables bound in FLWOR, typeswitch, or quantified expressions
may not appear on the left-hand side of an assignment.</p>
</div>
<p>The expression on the right-hand side is evaluated, resulting in
an <a title="XDM instance" href="#dt-xdm-instance">XDM instance</a>
and a <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
<p>If the <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> returned by the expression on the right-hand side does
not match the declared type of the variable according to
SequenceType matching rules, a type error is raised [<a href=
"http://www.w3.org/TR/xquery#ERRXPTY0004" title=
"err:XPTY0004">err:XPTY0004</a>]<sup><small>XQ</small></sup>. If
the types match, the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> returned by the expression is
bound to the variable (added to <em>variable values</em> in the
<em>dynamic context</em>.)</p>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the expression on the right-hand side is
applied using <code>upd:applyUpdates</code>.</p>
<p>The result of an Assignment Expression is an empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and an
empty <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-while" id="id-while"></a>5.4 While Expression</h3>
<h5><a name="d7e1522" id="d7e1522"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhileExpr" id=
"doc-xquery-WhileExpr"></a>[<small>160</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-WhileExpr"></a><a href=
"#prod-xquery-WhileExpr">WhileExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"while" "(" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ")" <a href=
"#doc-xquery-WhileBody">WhileBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhileBody" id=
"doc-xquery-WhileBody"></a>[<small>161</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-WhileBody"></a><a href=
"#prod-xquery-WhileBody">WhileBody</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-Block">Block</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>[<a name="dt-test-expr" id="dt-test-expr" title=
"test expression">Definition</a>: The expression enclosed in the
parentheses of a while expression is called a <b>test
expression</b>.] The <a title="test expression" href=
"#dt-test-expr">test expression</a> may be in any category.</p>
<p>A static error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if the WhileBody is an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
<p>A while expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>The while expression is used for conditional iteration. It is
evaluated as follows:</p>
<p>The <a title="test expression" href="#dt-test-expr">test
expression</a> is evaluated, resulting in an <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and a
<a title="pending update list" href="#dt-pul">pending update
list</a>. The <a title="pending update list" href="#dt-pul">pending
update list</a> returned by the <a title="test expression" href=
"#dt-test-expr">test expression</a> is applied using
<code>upd:applyUpdates</code>.</p>
<p>If the effective Boolean value of the <a title="test expression"
href="#dt-test-expr">test expression</a> is false, the block is not
evaluated. If the effective Boolean value of the <a title=
"test expression" href="#dt-test-expr">test expression</a> is true,
the block is evaluated repeatedly. Each evaluation of the block may
cause side effects that affect the result of re-evaluating the
<a title="test expression" href="#dt-test-expr">test
expression</a>. The <a title="test expression" href=
"#dt-test-expr">test expression</a> is re-evaluated after each
evaluation of the block. This process continues until the effective
Boolean value of the <a title="test expression" href=
"#dt-test-expr">test expression</a> is evaluated to be false.</p>
<p>The result of a while expression is an empty <a title=
"XDM instance" href="#dt-xdm-instance">XDM instance</a> and an
empty <a title="pending update list" href="#dt-pul">pending update
list</a>.</p>
</dd>
<dt class="label">Example:</dt>
<dd>
<p>In the following query, a while expression is used to compute a
sequence containing all the Fibonacci numbers that are less than
100.</p>
<div class="exampleInner">
<pre>
block {
declare $a as xs:integer := 0;
declare $b as xs:integer := 1;
declare $c as xs:integer := $a + $b;
declare $fibseq as xs:integer* := ($a, $b);
while ($c &lt; 100) {
$fibseq := ($fibseq, $c);
$a := $b;
$b := $c;
$c := $a + $b;
};
$fibseq;
}
</pre></div>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-exit" id="id-exit"></a>5.5 Exit Expression</h3>
<h5><a name="d7e1631" id="d7e1631"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ExitExpr" id=
"doc-xquery-ExitExpr"></a>[<small>159</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExitExpr"></a><a href=
"#prod-xquery-ExitExpr">ExitExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"exit" "returning" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The operand of an exit expression may be an expression of any
category.</p>
<p>An exit expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt class="label">Semantics:</dt>
<dd>
<p>An exit expression serves to define the result of the enclosing
function or query body.</p>
<p>The operand expression of the exit expression is evaluated,
resulting in an <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> and a <a title="pending update list" href=
"#dt-pul">pending update list</a>. The <a title=
"pending update list" href="#dt-pul">pending update list</a>
returned by the operand expression is applied using
<code>upd:applyUpdates</code>.</p>
<p>If an exit expression is evaluated within the body of a
function, further evaluation of the function body is interrupted
and the <a title="XDM instance" href="#dt-xdm-instance">XDM
instance</a> returned by the operand expression is returned as the
result of the function call.</p>
<p>If an exit expression is evaluated within a query body (i.e.,
not within the body of a function), further evaluation of the query
is interrupted and the <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> returned by the operand
expression is returned as the result of the query.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>An exit expression in a block terminates evaluation of the
enclosing function body or query, not just the immediately
enclosing block.</p>
</div>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-query-mode-pragma" id=
"id-query-mode-pragma"></a>5.6 Query Mode Pragma</h3>
<h5><a name="d7e1688" id="d7e1688"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ExtensionExpr" id=
"doc-xquery-ExtensionExpr"></a>[<small>67</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExtensionExpr"></a><a href=
"#prod-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-Pragma">Pragma</a>+ "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Pragma" id=
"doc-xquery-Pragma"></a>[<small>68</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Pragma"></a><a href=
"#prod-xquery-Pragma">Pragma</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"(#" <a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-QName">QName</a> (<a href="#prod-xquery-S">S</a>
<a href="#doc-xquery-PragmaContents">PragmaContents</a>)?
"#)"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PragmaContents" id=
"doc-xquery-PragmaContents"></a>[<small>69</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PragmaContents"></a><a href=
"#prod-xquery-PragmaContents">PragmaContents</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '#)'
Char*))</code></td>
</tr>
</tbody>
</table>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines the QName
<code>xqsx:query-mode</code> as a well-known pragma name for use in
an ExtensionExpr, which sets the <a title="query mode" href=
"#dt-query-mode">query mode</a> in the static context for the
enclosed expression to the value specified. A static error is
raised [<a href="#ERRSXST0009" title=
"err:SXST0009">err:SXST0009</a>] if the value for a
<code>xqsx:query-mode</code> pragma is not either
<code>sequential</code> or <code>simple</code>.</p>
<p>Implementations of <a title="XQSX" href="#dt-xqsx">XQSX</a> must
recognize the pragma namespace URI
<code>http://www.w3.org/2008/xquery-sx-10</code>, and the pragma
name <code>xqsx:query-mode</code>.</p>
</div>
</div>
<div class="div1">
<h2><a name="id-existing-exprs" id="id-existing-exprs"></a>6
Changes to Existing Expressions</h2>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> imposes new category
rules, evaluation order and additional semantics on top of existing
<a href="#XQ10">[XQuery 1.0]</a> and <a href=
"#XQueryUpdate">[XQuery Update Facility]</a> expressions, detailed
in this section.</p>
<div class="div2">
<h3><a name="id-parenthesized-expr" id=
"id-parenthesized-expr"></a>6.1 Parentheses</h3>
<h5><a name="d7e1774" id="d7e1774"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ParenthesizedExpr" id=
"doc-xquery-ParenthesizedExpr"></a>[<small>91</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ParenthesizedExpr"></a><a href=
"#prod-xquery-ParenthesizedExpr">ParenthesizedExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"(" <a href="#prod-xquery-Expr">Expr</a>? ")"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>An expression of any category may be enclosed in parentheses;
the resulting expression has the same category as the original
expression. An empty parenthesized expression <code>( )</code> is a
<a title="simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-function-call" id="id-function-call"></a>6.2
Function Calls</h3>
<h5><a name="d7e1800" id="d7e1800"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FunctionCall" id=
"doc-xquery-FunctionCall"></a>[<small>95</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FunctionCall"></a><a href=
"#prod-xquery-FunctionCall">FunctionCall</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a> "(" (<a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*)? ")"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>If the function called is a <a title="simple function" href=
"#dt-simple-function">simple function</a>, the argument expressions
<span>can either be all <a title="simple expression" href=
"#dt-simple-expr">simple</a> and <a title="updating expression"
href="#dt-updating-expr">updating expressions</a>, or all <a title=
"simple expression" href="#dt-simple-expr">simple</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</span> If the argument expressions contain an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a> then the function call is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, <span>if they contain a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a> then the function call is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>,</span> otherwise it is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
<p>If the function called is an <a title="updating function" href=
"#dt-updating-function">updating function</a>, the argument
expressions must be <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a> or <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>. The function call is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
<p>If the function called is a <a title="sequential function" href=
"#dt-sequential-function">sequential function</a>, the argument
expressions must be <a title="simple expression" href=
"#dt-simple-expr">simple expressions</a> <span>or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a></span> . The function call expression is a
<a title="updating expression" href="#dt-updating-expr">sequential
expression</a>.</p>
<p>If the arguments of a function call violate the category rules
for the function's category, [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Argument expressions are evaluated from left to right, then the
function is invoked.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by the argument expressions are merged with the
<a title="pending update list" href="#dt-pul">pending update
list</a> returned by the function itself by calling
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-path-expr" id="id-path-expr"></a>6.3 Path
Expressions</h3>
<h5><a name="d7e1926" id="d7e1926"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PathExpr" id=
"doc-xquery-PathExpr"></a>[<small>70</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PathExpr"></a><a href=
"#prod-xquery-PathExpr">PathExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("/" <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a>?)<br />
| ("//" <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a>)<br />
| <a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-RelativePathExpr" id=
"doc-xquery-RelativePathExpr"></a>[<small>71</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-RelativePathExpr"></a><a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-StepExpr">StepExpr</a> (("/" |
"//") <a href="#prod-xquery-StepExpr">StepExpr</a>)*</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a path expression is determined by the following
rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any StepExpr in the
RelativePathExpr is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If any StepExpr in the RelativePathExpr is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, then all StepExpr must be <a title=
"updating expression" href="#dt-updating-expr">updating</a> or
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. In this
case, the path expression is an <a title="updating expression"
href="#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any StepExpr in the RelativePathExpr is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, then all StepExpr must be <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
or <a title="simple expression" href="#dt-simple-expr">simple
expressions</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. In this
case, the path expression is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the path expression is a <a title="simple expression"
href="#dt-simple-expr">simple expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>StepExpr are evaluated in order from left to right.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by each of the StepExpr are merged by calling
<code>upd:mergeUpdates</code>, and returned as part of the result
of the path expression.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-predicate" id="id-predicate"></a>6.4
Predicates</h3>
<h5><a name="d7e2041" id="d7e2041"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-AxisStep" id=
"doc-xquery-AxisStep"></a>[<small>73</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AxisStep"></a><a href=
"#prod-xquery-AxisStep">AxisStep</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-ReverseStep">ReverseStep</a> |
<a href="#prod-xquery-ForwardStep">ForwardStep</a>) <a href=
"#doc-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FilterExpr" id=
"doc-xquery-FilterExpr"></a>[<small>83</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FilterExpr"></a><a href=
"#prod-xquery-FilterExpr">FilterExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PrimaryExpr">PrimaryExpr</a>
<a href="#doc-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PredicateList" id=
"doc-xquery-PredicateList"></a>[<small>84</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PredicateList"></a><a href=
"#prod-xquery-PredicateList">PredicateList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#doc-xquery-Predicate">Predicate</a>*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-Predicate" id=
"doc-xquery-Predicate"></a>[<small>85</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Predicate"></a><a href=
"#prod-xquery-Predicate">Predicate</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"[" <a href="#prod-xquery-Expr">Expr</a> "]"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a FilterExpr or AxisStep is determined by the
following rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if the primary
expression or a predicate expression of any FilterExpr or AxisStep
is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If either the primary expression or any predicate expression of
a FilterExpr or AxisStep is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all such
expressions must be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the FilterExpr or
AxisStep is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If either the primary expression or any predicate expression of
a FilterExpr or AxisStep is a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>, then all such
expressions must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the FilterExpr or
AxisStep is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the FilterExpr or AxisStep is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>First the reverse step, forward step or primary expression is
evaluated, then predicates are evaluated from left to right. Each
predicate expression must be evaluated to completion before the
next is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the primary expression is merged with the
<a title="pending update list" href="#dt-pul">pending update
lists</a> returned by the predicate expressions by calling
<code>upd:mergeUpdates</code>. The resulting pending update list is
returned as part of the result of the FilterExpr or AxisStep.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-concat-expr" id="id-concat-expr"></a>6.5
Concatenation Expressions</h3>
<h5><a name="d7e2169" id="d7e2169"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ConcatExpr" id=
"doc-xquery-ConcatExpr"></a>[<small>33</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ConcatExpr"></a><a href=
"#prod-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a concatenation expression is determined by the
following rules:</p>
<ul>
<li>
<p>If any operand is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all operands must
be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the concatenation
expression is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any operand is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all operands
must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the concatenation
expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the concatenation expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Operand expressions are evaluated once, from left to right. Side
effects of each sequential operand expression are visible to
subsequent operand expressions.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The concatenation expression evaluates each of its operands and
concatenates the resulting <a title="XDM instance" href=
"#dt-xdm-instance">XDM instances</a> and <a title=
"pending update list" href="#dt-pul">pending update lists</a>, in
order. <a title="pending update list" href="#dt-pul">Pending update
lists</a> are concatenated by the <code>upd:mergeUpdates</code>
operation.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-node-constructors" id=
"id-node-constructors"></a>6.6 Direct and Computed Node
Constructors</h3>
<h5><a name="d7e2256" id="d7e2256"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirElemConstructor" id=
"doc-xquery-DirElemConstructor"></a>[<small>98</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-DirElemConstructor"></a><a href=
"#prod-xquery-DirElemConstructor">DirElemConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;" <a href="#prod-xquery-QName">QName</a> <a href=
"#doc-xquery-DirAttributeList">DirAttributeList</a> ("/&gt;" |
("&gt;" <a href="#prod-xquery-DirElemContent">DirElemContent</a>*
"&lt;/" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-S">S</a>? "&gt;"))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirAttributeList" id=
"doc-xquery-DirAttributeList"></a>[<small>99</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-DirAttributeList"></a><a href=
"#prod-xquery-DirAttributeList">DirAttributeList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-S">S</a> (<a href=
"#prod-xquery-QName">QName</a> <a href="#prod-xquery-S">S</a>? "="
<a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-DirAttributeValue">DirAttributeValue</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CDataSection" id=
"doc-xquery-CDataSection"></a>[<small>109</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CDataSection"></a><a href=
"#prod-xquery-CDataSection">CDataSection</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;![CDATA[" <a href=
"#prod-xquery-CDataSectionContents">CDataSectionContents</a>
"]]&gt;"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirPIConstructor" id=
"doc-xquery-DirPIConstructor"></a>[<small>107</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-DirPIConstructor"></a><a href=
"#prod-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;?" <a href="#prod-xquery-PITarget">PITarget</a>
(<a href="#prod-xquery-S">S</a> <a href=
"#prod-xquery-DirPIContents">DirPIContents</a>)?
"?&gt;"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DirCommentConstructor" id=
"doc-xquery-DirCommentConstructor"></a>[<small>105</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-DirCommentConstructor"></a><a href=
"#prod-xquery-DirCommentConstructor">DirCommentConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;!--" <a href=
"#prod-xquery-DirCommentContents">DirCommentContents</a>
"--&gt;"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompElemConstructor" id=
"doc-xquery-CompElemConstructor"></a>[<small>113</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CompElemConstructor"></a><a href=
"#prod-xquery-CompElemConstructor">CompElemConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"element" (<a href="#prod-xquery-QName">QName</a> | ("{"
<a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-ContentExpr">ContentExpr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompAttrConstructor" id=
"doc-xquery-CompAttrConstructor"></a>[<small>115</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CompAttrConstructor"></a><a href=
"#prod-xquery-CompAttrConstructor">CompAttrConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"attribute" (<a href="#prod-xquery-QName">QName</a> |
("{" <a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompDocConstructor" id=
"doc-xquery-CompDocConstructor"></a>[<small>112</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CompDocConstructor"></a><a href=
"#prod-xquery-CompDocConstructor">CompDocConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"document" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompTextConstructor" id=
"doc-xquery-CompTextConstructor"></a>[<small>116</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CompTextConstructor"></a><a href=
"#prod-xquery-CompTextConstructor">CompTextConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"text" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompPIConstructor" id=
"doc-xquery-CompPIConstructor"></a>[<small>118</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CompPIConstructor"></a><a href=
"#prod-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"processing-instruction" (<a href=
"#prod-xquery-NCName">NCName</a> | ("{" <a href=
"#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-CompCommentConstructor" id=
"doc-xquery-CompCommentConstructor"></a>[<small>117</small>]&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-CompCommentConstructor"></a><a href="#prod-xquery-CompCommentConstructor">CompCommentConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"comment" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a node constructor is determined by the
following rules:</p>
<ul>
<li>
<p>If any operand is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all operands must
be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the node
constructor is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any operand is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all operands
must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the node
constructor is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the node constructor is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<ol class="enumar">
<li>
<p>The name expression is evaluated (computed
element/attribute/processing-instruction constructors only).</p>
</li>
<li>
<p>The direct attribute constructors are evaluated from left to
right (direct element constructors only).</p>
</li>
<li>
<p>The child or value expressions are evaluated from left to
right.</p>
</li>
</ol>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
lists</a> from each operand expression are concatenated by the
<code>upd:mergeUpdates</code> operation, producing the resulting
pending update list.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-FLWOR-expr" id="id-FLWOR-expr"></a>6.7 FLWOR
Expressions</h3>
<h5><a name="d7e2472" id="d7e2472"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-FLWORExpr" id=
"doc-xquery-FLWORExpr"></a>[<small>35</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FLWORExpr"></a><a href=
"#prod-xquery-FLWORExpr">FLWORExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#doc-xquery-ForClause">ForClause</a> | <a href=
"#doc-xquery-LetClause">LetClause</a>)+ <a href=
"#doc-xquery-WhereClause">WhereClause</a>? <a href=
"#doc-xquery-OrderByClause">OrderByClause</a>? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ForClause" id=
"doc-xquery-ForClause"></a>[<small>36</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ForClause"></a><a href=
"#prod-xquery-ForClause">ForClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"for" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>?
<a href="#doc-xquery-PositionalVar">PositionalVar</a>? "in"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? <a href=
"#doc-xquery-PositionalVar">PositionalVar</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-PositionalVar" id=
"doc-xquery-PositionalVar"></a>[<small>37</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PositionalVar"></a><a href=
"#prod-xquery-PositionalVar">PositionalVar</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"at" "$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-LetClause" id=
"doc-xquery-LetClause"></a>[<small>38</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-LetClause"></a><a href=
"#prod-xquery-LetClause">LetClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"let" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-WhereClause" id=
"doc-xquery-WhereClause"></a>[<small>39</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-WhereClause"></a><a href=
"#prod-xquery-WhereClause">WhereClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"where" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderByClause" id=
"doc-xquery-OrderByClause"></a>[<small>40</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OrderByClause"></a><a href=
"#prod-xquery-OrderByClause">OrderByClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(("order" "by") | ("stable" "order" "by")) <a href=
"#doc-xquery-OrderSpecList">OrderSpecList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderSpecList" id=
"doc-xquery-OrderSpecList"></a>[<small>41</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OrderSpecList"></a><a href=
"#prod-xquery-OrderSpecList">OrderSpecList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OrderSpec">OrderSpec</a> (","
<a href="#doc-xquery-OrderSpec">OrderSpec</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderSpec" id=
"doc-xquery-OrderSpec"></a>[<small>42</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OrderSpec"></a><a href=
"#prod-xquery-OrderSpec">OrderSpec</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> <a href=
"#doc-xquery-OrderModifier">OrderModifier</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-OrderModifier" id=
"doc-xquery-OrderModifier"></a>[<small>43</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OrderModifier"></a><a href=
"#prod-xquery-OrderModifier">OrderModifier</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("ascending" | "descending")? ("empty" ("greatest" |
"least"))? ("collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a>)?</code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The <code>for</code>, <code>let</code>, <code>where</code>, and
<code>order by</code> clauses <span>can either be all <a title=
"simple expression" href="#dt-simple-expr">simple</a></span>
<span>and <a title="updating expression" href=
"#dt-updating-expr">updating expressions</a>, or all <a title=
"simple expression" href="#dt-simple-expr">simple</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expressions</a>.</span></p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any <code>for</code>,
<code>let</code>, <code>where</code>, or <code>order by</code>
clause is an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>If the above clauses contain an <a title="updating expression"
href="#dt-updating-expr">updating expression</a>, then all clauses
must either be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> or an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. The FLWOR
expression itself is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If the above clauses contain a <a title="sequential expression"
href="#dt-sequential-expr">sequential expression</a>, then all
clauses must either be a <a title="simple expression" href=
"#dt-simple-expr">simple expression</a> or an <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, otherwise a static error is raised [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>]. The FLWOR
expression itself is an <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>If the above clauses do not contain an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a> <span>or a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a></span>, then the
<code>return</code> clause may be an expression of any category.
The category of the FLWOR expression is the same as the category of
the expression in its <code>return</code> clause.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<ul>
<li>
<p><em>For Clause:</em> The associated expression is evaluated
first to produce the binding sequnce, then the next clause is
evaluated once for each item in the binding sequence. Any side
effects in the associated expression are visible to the evaluation
of the next clause.</p>
</li>
<li>
<p><em>Let Clause:</em> The associated expression is evaluated
first to produce the binding sequnce, then the next clause is
evaluated. Any side effects in the associated expression are
visible to the evaluation of the next clause.</p>
</li>
<li>
<p><em>Where Clause:</em> The where expression is evaluated once,
then the next clause is evaluated. Any side effects in the where
expression are visible to the evaluation of the next clause.</p>
</li>
<li>
<p><em>Order By Clause:</em> The orderspecs are evaluated from left
to right on each tuple in the tuple stream. The tuple stream is
reordered, then the next clause is evaluated.</p>
</li>
<li>
<p><em>Return Clause:</em> The return expresion is evaluated
once.</p>
</li>
</ul>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The result of a FLWOR expression is the concatenation of the
<a title="XDM instance" href="#dt-xdm-instance">XDM instances</a>
or <a title="pending update list" href="#dt-pul">pending update
lists</a> returned by successive evaluations of the
<code>return</code> clause in evaluation order, as well as the
<a title="pending update list" href="#dt-pul">pending update
lists</a> returned by any of the other FLWOR clauses. <a title=
"pending update list" href="#dt-pul">Pending update lists</a> are
concatenated by the <code>upd:mergeUpdates</code> operation.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-conditional-expr" id="id-conditional-expr"></a>6.8
Conditional Expressions</h3>
<h5><a name="d7e2785" id="d7e2785"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-IfExpr" id=
"doc-xquery-IfExpr"></a>[<small>47</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-IfExpr"></a><a href=
"#prod-xquery-IfExpr">IfExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"if" "(" <a href="#prod-xquery-Expr">Expr</a> ")" "then"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> "else" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The test, then and else expressions can be of any type. An error
[<a href="#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>] is
raised if one of the expressions is <a title="updating expression"
href="#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If the test, then or else expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the conditional expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If the test, then or else expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the conditional expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the conditional expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The test expression is evaluated first. Next either the then
expression or the else expression (but not both) is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the conditional expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the test expression and the executed branch
of the conditional expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-quantified-expr" id="id-quantified-expr"></a>6.9
Quantified Expressions</h3>
<h5><a name="d7e2914" id="d7e2914"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-QuantifiedExpr" id=
"doc-xquery-QuantifiedExpr"></a>[<small>44</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QuantifiedExpr"></a><a href=
"#prod-xquery-QuantifiedExpr">QuantifiedExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("some" | "every") "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "satisfies" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The category of a quantified expression is determined by the
following rules:</p>
<ul>
<li>
<p>If <a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>, [<a href="#ERRXUST0001" title=
"err:XUST0001">err:XUST0001</a>] is raised if any quantified
expression clause or the satisfies expression is an <a title=
"updating expression" href="#dt-updating-expr">updating</a> or
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>If any quantified expression clause or the satisfies expression
is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>, then all such
expressions must be <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title="simple expression"
href="#dt-simple-expr">simple expressions</a>, otherwise a static
error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the quantified
expression is an <a title="updating expression" href=
"#dt-updating-expr">updating expression</a>.</p>
</li>
<li>
<p>If any quantified expression clause or the satisfies expression
is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>, then all such
expressions must be <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a> or <a title=
"simple expression" href="#dt-simple-expr">simple expressions</a>,
otherwise a static error is raised [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>]. In this case, the quantified
expression is a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</li>
<li>
<p>Otherwise, the quantified expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The quantified expression clauses are initially evaluated as
specified by <a href="#XQ10">[XQuery 1.0]</a>, generating a tuple
stream. Then the satisfies clause is evaluated once for each tuple
in the tuple stream, in order. If the satisfies clause contains a
sequential expression, the side effects of each iteration are
visible to subsequent evaluations of the return clause.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the quantified expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the quantified expression clauses and the
satisfies expression using <code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-typeswitch-expr" id="id-typeswitch-expr"></a>6.10
Typeswitch Expressions</h3>
<h5><a name="d7e3034" id="d7e3034"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TypeswitchExpr" id=
"doc-xquery-TypeswitchExpr"></a>[<small>45</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-TypeswitchExpr"></a><a href=
"#prod-xquery-TypeswitchExpr">TypeswitchExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"typeswitch" "(" <a href="#prod-xquery-Expr">Expr</a> ")"
<a href="#prod-xquery-CaseClause">CaseClause</a>+ "default" ("$"
<a href="#prod-xquery-VarName">VarName</a>)? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The operand, case and default expressions can be of any type. An
error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if one of the
expressions is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If an operand, case or default expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the typeswitch expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If an operand, case or default expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the typeswitch expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the typeswitch expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>The operand expression is evaluated first. Then, exactly one of
the return expressions is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the typeswitch expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the operand expression and the executed
branch of the typeswitch expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-update-expr" id="id-update-expr"></a>6.11 Insert,
Delete, Replace, and Rename Expressions</h3>
<h5><a name="d7e3172" id="d7e3172"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-InsertExpr" id=
"doc-xquery-InsertExpr"></a>[<small>145</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-InsertExpr"></a><a href=
"#prod-xquery-InsertExpr">InsertExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"insert" ("node" | "nodes") <a href=
"#doc-xquery-SourceExpr">SourceExpr</a> <a href=
"#doc-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a>
<a href="#doc-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-InsertExprTargetChoice" id=
"doc-xquery-InsertExprTargetChoice"></a>[<small>144</small>]&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-InsertExprTargetChoice"></a><a href="#prod-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(("as" ("first" | "last"))? "into")<br />
| "after"<br />
| "before"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-DeleteExpr" id=
"doc-xquery-DeleteExpr"></a>[<small>146</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-DeleteExpr"></a><a href=
"#prod-xquery-DeleteExpr">DeleteExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"delete" ("node" | "nodes") <a href=
"#doc-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-ReplaceExpr" id=
"doc-xquery-ReplaceExpr"></a>[<small>147</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ReplaceExpr"></a><a href=
"#prod-xquery-ReplaceExpr">ReplaceExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"replace" ("value" "of")? "node" <a href=
"#doc-xquery-TargetExpr">TargetExpr</a> "with" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-RenameExpr" id=
"doc-xquery-RenameExpr"></a>[<small>148</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-RenameExpr"></a><a href=
"#prod-xquery-RenameExpr">RenameExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"rename" "node" <a href=
"#doc-xquery-TargetExpr">TargetExpr</a> "as" <a href=
"#doc-xquery-NewNameExpr">NewNameExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-SourceExpr" id=
"doc-xquery-SourceExpr"></a>[<small>149</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-SourceExpr"></a><a href=
"#prod-xquery-SourceExpr">SourceExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TargetExpr" id=
"doc-xquery-TargetExpr"></a>[<small>150</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-TargetExpr"></a><a href=
"#prod-xquery-TargetExpr">TargetExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-NewNameExpr" id=
"doc-xquery-NewNameExpr"></a>[<small>151</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-NewNameExpr"></a><a href=
"#prod-xquery-NewNameExpr">NewNameExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>Insert, delete, replace, and rename expressions are <a title=
"updating expression" href="#dt-updating-expr">updating
expressions</a>, and are extended to accept both <a title=
"updating expression" href="#dt-updating-expr">updating</a> and
<a title="simple expression" href="#dt-simple-expr">simple
expressions</a> as their operands. It is a static error [<a href=
"#ERRSXST0002" title="err:SXST0002">err:SXST0002</a>] for the
operand of one of these expressions to be a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Order of evaluation for insert, delete, replace, and rename
expressions is irrelevent since their operands cannot be sequential
expressions.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by insert, delete, replace, and rename
expressions is calculated by merging the <a title=
"pending update list" href="#dt-pul">pending update lists</a> from
the operands of the expression and the <a title=
"pending update list" href="#dt-pul">pending update list</a>
produced by the expression itself using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-transform-expr" id="id-transform-expr"></a>6.12
Transform Expressions</h3>
<h5><a name="d7e3289" id="d7e3289"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="doc-xquery-TransformExpr" id=
"doc-xquery-TransformExpr"></a>[<small>152</small>]&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-TransformExpr"></a><a href=
"#prod-xquery-TransformExpr">TransformExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"copy" "$" <a href="#prod-xquery-VarName">VarName</a>
":=" <a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$"
<a href="#prod-xquery-VarName">VarName</a> ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "modify" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
</table>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>The copy, modify and return clauses of a transform expression
can be of any type. An error [<a href="#ERRSXST0002" title=
"err:SXST0002">err:SXST0002</a>] is raised if one of the copy or
return clauses is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and either the copy, modify or
return clauses is <a title="sequential expression" href=
"#dt-sequential-expr">sequential</a>.</p>
<ul>
<li>
<p>If one of the copy or return clauses is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>, the transform expression is an <a title=
"updating expression" href="#dt-updating-expr">updating
expression</a>.</p>
</li>
<li>
<p>If one of the copy, modify or return clauses is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>, the transform expression is a <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a>.</p>
</li>
<li>
<p>Otherise, the transform expression is a <a title=
"simple expression" href="#dt-simple-expr">simple
expression</a>.</p>
</li>
</ul>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Copy clauses are evaluated in order, then the modify expression
is evaluated. Finally the return clause is evaluated.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The semantics of a transform expression as defined in <a href=
"http://www.w3.org/TR/xquery-update-10/#id-transform">Section 2.4.5
Transform</a><sup><small>XU</small></sup> are extended as
follows:</p>
<ul>
<li>
<p>If the modify clause returns a non-empty <a title="XDM instance"
href="#dt-xdm-instance">XDM instance</a> it is discarded.</p>
</li>
<li>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by the transform expression is calculated by
merging the <a title="pending update list" href="#dt-pul">pending
update lists</a> from the copy clause and the return clause using
<code>upd:mergeUpdates</code>.</p>
</li>
</ul>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-other-expr" id="id-other-expr"></a>6.13 Other
Expressions</h3>
<p>All expressions not listed above are extended as follows. This
includes the following kinds of expressions:</p>
<ul>
<li>
<p>Range expressions</p>
</li>
<li>
<p>Union, intersect, and except expressions</p>
</li>
<li>
<p>Arithmetic, comparison, and logical expressions</p>
</li>
<li>
<p>Ordered and unordered expressions</p>
</li>
<li>
<p>Instance of, cast, castable, and treat expressions</p>
</li>
<li>
<p>Validate expressions</p>
</li>
<li>
<p>Extension expressions (pragmas)</p>
</li>
</ul>
<dl>
<dt class="label">Category Rules:</dt>
<dd>
<p>All other expressions are extended to accept any type of
expressions as their operands. An error [<a href="#ERRSXST0002"
title="err:SXST0002">err:SXST0002</a>] is raised if one of the
operands is <a title="updating expression" href=
"#dt-updating-expr">updating</a> and another is <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>.
If an operand of the expression is <a title="updating expression"
href="#dt-updating-expr">updating</a> then the expression itself is
<a title="updating expression" href=
"#dt-updating-expr">updating</a>, if an operand is <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
then the expression itself is <a title="sequential expression"
href="#dt-sequential-expr">sequential</a>, otherwise it is
<a title="simple expression" href="#dt-simple-expr">simple</a>.</p>
</dd>
<dt class="label">Evaluation Order:</dt>
<dd>
<p>Operand expressions are evaluated once, from left to right.</p>
</dd>
<dt class="label">Additional Semantics:</dt>
<dd>
<p>The <a title="pending update list" href="#dt-pul">pending update
list</a> returned by any other expression is calculated by merging
the <a title="pending update list" href="#dt-pul">pending update
lists</a> from the operands of that expression using
<code>upd:mergeUpdates</code>.</p>
</dd>
</dl>
</div>
</div>
<div class="div1">
<h2><a name="id-example" id="id-example"></a>7 Example</h2>
<p>The following function returns <code>true</code> or
<code>false</code> according to whether its parameter is a known
user name, and logs the event:</p>
<div class="exampleInner">
<pre>
declare sequential function validate-and-log($username as xs:string)
as xs:boolean {
declare $log as document-node() := fn:doc("log.xml");
declare $entry as element() :=
&lt;access-attempt&gt;
&lt;timestamp&gt;{fn:current-dateTime()}&lt;/timestamp&gt;
&lt;user-name&gt;{$username}&lt;/user-name&gt;
&lt;access-allowed/&gt;
&lt;/access-attempt&gt; ;
declare $result as xs:boolean;
if ($username = doc("users.xml")/current-users/user/name )
then (
replace value of node $entry/access-allowed with "Yes";
$result := true();
) else (
replace value of node $entry/access-allowed with "No";
$result := false();
);
insert node $entry as last into $log;
fn:put($log, "log.xml");
exit returning $result;
}
</pre></div>
</div>
</div>
<div class="back">
<div class="div1">
<h2><a name="id-grammar" id="id-grammar"></a>A EBNF for XQuery 1.0
Grammar with Scripting Extensions</h2>
<p>The EBNF in this document and in this section is aligned with
the current XML Query 1.0 grammar (see <a href="#XQ10">[XQuery
1.0]</a>).</p>
<h5><a name="d7e3564" id="d7e3564"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Module" id=
"prod-xquery-Module"></a>[<small>1</small>]&#160;&#160;&#160;</td>
<td><code>Module</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-VersionDecl">VersionDecl</a>?
(<a href="#prod-xquery-LibraryModule">LibraryModule</a> | <a href=
"#prod-xquery-MainModule">MainModule</a>)</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VersionDecl" id=
"prod-xquery-VersionDecl"></a>[<small>2</small>]&#160;&#160;&#160;</td>
<td><code>VersionDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"xquery" "version" <a href=
"#prod-xquery-StringLiteral">StringLiteral</a> ("encoding" <a href=
"#prod-xquery-StringLiteral">StringLiteral</a>)? <a href=
"#prod-xquery-Separator">Separator</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-MainModule" id=
"prod-xquery-MainModule"></a>[<small>3</small>]&#160;&#160;&#160;</td>
<td><code>MainModule</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Prolog">Prolog</a> <a href=
"#prod-xquery-QueryBody">QueryBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-LibraryModule" id=
"prod-xquery-LibraryModule"></a>[<small>4</small>]&#160;&#160;&#160;</td>
<td><code>LibraryModule</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ModuleDecl">ModuleDecl</a> <a href=
"#prod-xquery-Prolog">Prolog</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ModuleDecl" id=
"prod-xquery-ModuleDecl"></a>[<small>5</small>]&#160;&#160;&#160;</td>
<td><code>ModuleDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"module" "namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=" <a href=
"#prod-xquery-URILiteral">URILiteral</a> <a href=
"#prod-xquery-Separator">Separator</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Prolog" id=
"prod-xquery-Prolog"></a>[<small>6</small>]&#160;&#160;&#160;</td>
<td><code>Prolog</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>((<a href=
"#prod-xquery-DefaultNamespaceDecl">DefaultNamespaceDecl</a> |
<a href="#prod-xquery-Setter">Setter</a> | <a href=
"#prod-xquery-NamespaceDecl">NamespaceDecl</a> | <a href=
"#prod-xquery-Import">Import</a>) <a href=
"#prod-xquery-Separator">Separator</a>)* ((<a href=
"#prod-xquery-VarDecl">VarDecl</a> | <a href=
"#prod-xquery-FunctionDecl">FunctionDecl</a> | <a href=
"#prod-xquery-OptionDecl">OptionDecl</a>) <a href=
"#prod-xquery-Separator">Separator</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Setter" id=
"prod-xquery-Setter"></a>[<small>7</small>]&#160;&#160;&#160;</td>
<td><code>Setter</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-BoundarySpaceDecl">BoundarySpaceDecl</a> | <a href=
"#prod-xquery-DefaultCollationDecl">DefaultCollationDecl</a> |
<a href="#prod-xquery-BaseURIDecl">BaseURIDecl</a> | <a href=
"#prod-xquery-ConstructionDecl">ConstructionDecl</a> | <a href=
"#prod-xquery-OrderingModeDecl">OrderingModeDecl</a> | <a href=
"#prod-xquery-EmptyOrderDecl">EmptyOrderDecl</a> | <a href=
"#prod-xquery-RevalidationDecl">RevalidationDecl</a> | <a href=
"#prod-xquery-CopyNamespacesDecl">CopyNamespacesDecl</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Import" id=
"prod-xquery-Import"></a>[<small>8</small>]&#160;&#160;&#160;</td>
<td><code>Import</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-SchemaImport">SchemaImport</a> |
<a href="#prod-xquery-ModuleImport">ModuleImport</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Separator" id=
"prod-xquery-Separator"></a>[<small>9</small>]&#160;&#160;&#160;</td>
<td><code>Separator</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>";"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NamespaceDecl" id=
"prod-xquery-NamespaceDecl"></a>[<small>10</small>]&#160;&#160;&#160;</td>
<td><code>NamespaceDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BoundarySpaceDecl" id=
"prod-xquery-BoundarySpaceDecl"></a>[<small>11</small>]&#160;&#160;&#160;</td>
<td><code>BoundarySpaceDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "boundary-space" ("preserve" |
"strip")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DefaultNamespaceDecl" id=
"prod-xquery-DefaultNamespaceDecl"></a>[<small>12</small>]&#160;&#160;&#160;</td>
<td><code>DefaultNamespaceDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "default" ("element" | "function") "namespace"
<a href="#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OptionDecl" id=
"prod-xquery-OptionDecl"></a>[<small>13</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OptionDecl"></a><a href=
"#doc-xquery-OptionDecl">OptionDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "option" <a href="#prod-xquery-QName">QName</a>
<a href="#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderingModeDecl" id=
"prod-xquery-OrderingModeDecl"></a>[<small>14</small>]&#160;&#160;&#160;</td>
<td><code>OrderingModeDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "ordering" ("ordered" |
"unordered")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EmptyOrderDecl" id=
"prod-xquery-EmptyOrderDecl"></a>[<small>15</small>]&#160;&#160;&#160;</td>
<td><code>EmptyOrderDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "default" "order" "empty" ("greatest" |
"least")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CopyNamespacesDecl" id=
"prod-xquery-CopyNamespacesDecl"></a>[<small>16</small>]&#160;&#160;&#160;</td>
<td><code>CopyNamespacesDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "copy-namespaces" <a href=
"#prod-xquery-PreserveMode">PreserveMode</a> "," <a href=
"#prod-xquery-InheritMode">InheritMode</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PreserveMode" id=
"prod-xquery-PreserveMode"></a>[<small>17</small>]&#160;&#160;&#160;</td>
<td><code>PreserveMode</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"preserve" | "no-preserve"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InheritMode" id=
"prod-xquery-InheritMode"></a>[<small>18</small>]&#160;&#160;&#160;</td>
<td><code>InheritMode</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"inherit" | "no-inherit"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DefaultCollationDecl" id=
"prod-xquery-DefaultCollationDecl"></a>[<small>19</small>]&#160;&#160;&#160;</td>
<td><code>DefaultCollationDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "default" "collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BaseURIDecl" id=
"prod-xquery-BaseURIDecl"></a>[<small>20</small>]&#160;&#160;&#160;</td>
<td><code>BaseURIDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "base-uri" <a href=
"#prod-xquery-URILiteral">URILiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaImport" id=
"prod-xquery-SchemaImport"></a>[<small>21</small>]&#160;&#160;&#160;</td>
<td><code>SchemaImport</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"import" "schema" <a href=
"#prod-xquery-SchemaPrefix">SchemaPrefix</a>? <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("at" <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("," <a href=
"#prod-xquery-URILiteral">URILiteral</a>)*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaPrefix" id=
"prod-xquery-SchemaPrefix"></a>[<small>22</small>]&#160;&#160;&#160;</td>
<td><code>SchemaPrefix</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("namespace" <a href="#prod-xquery-NCName">NCName</a>
"=") | ("default" "element" "namespace")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ModuleImport" id=
"prod-xquery-ModuleImport"></a>[<small>23</small>]&#160;&#160;&#160;</td>
<td><code>ModuleImport</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"import" "module" ("namespace" <a href=
"#prod-xquery-NCName">NCName</a> "=")? <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("at" <a href=
"#prod-xquery-URILiteral">URILiteral</a> ("," <a href=
"#prod-xquery-URILiteral">URILiteral</a>)*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarDecl" id=
"prod-xquery-VarDecl"></a>[<small>24</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-VarDecl"></a><a href=
"#doc-xquery-VarDecl">VarDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" ("unassignable"? | "assignable") "variable" "$"
<a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ((":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>) | "external")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ConstructionDecl" id=
"prod-xquery-ConstructionDecl"></a>[<small>25</small>]&#160;&#160;&#160;</td>
<td><code>ConstructionDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "construction" ("strip" |
"preserve")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FunctionDecl" id=
"prod-xquery-FunctionDecl"></a>[<small>26</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-FunctionDecl"></a><a href=
"#doc-xquery-FunctionDecl">FunctionDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("declare" ("simple"? | "updating") "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a> | "external"))<br />
| ("declare" "sequential" "function" <a href=
"#prod-xquery-QName">QName</a> "(" <a href=
"#prod-xquery-ParamList">ParamList</a>? ")" ("as" <a href=
"#prod-xquery-SequenceType">SequenceType</a>)? (<a href=
"#prod-xquery-Block">Block</a> | "external"))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ParamList" id=
"prod-xquery-ParamList"></a>[<small>27</small>]&#160;&#160;&#160;</td>
<td><code>ParamList</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Param">Param</a> ("," <a href=
"#prod-xquery-Param">Param</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Param" id=
"prod-xquery-Param"></a>[<small>28</small>]&#160;&#160;&#160;</td>
<td><code>Param</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"$" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EnclosedExpr" id=
"prod-xquery-EnclosedExpr"></a>[<small>29</small>]&#160;&#160;&#160;</td>
<td><code>EnclosedExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"{" <a href="#prod-xquery-Expr">Expr</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QueryBody" id=
"prod-xquery-QueryBody"></a>[<small>30</small>]&#160;&#160;&#160;</td>
<td><code>QueryBody</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Expr" id=
"prod-xquery-Expr"></a>[<small>31</small>]&#160;&#160;&#160;</td>
<td><code>Expr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ApplyExpr">ApplyExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ApplyExpr" id=
"prod-xquery-ApplyExpr"></a>[<small>32</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ApplyExpr"></a><a href=
"#doc-xquery-ApplyExpr">ApplyExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ConcatExpr">ConcatExpr</a> (";"
(<a href="#prod-xquery-ConcatExpr">ConcatExpr</a>
";")*)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ConcatExpr" id=
"prod-xquery-ConcatExpr"></a>[<small>33</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ConcatExpr"></a><a href=
"#doc-xquery-ConcatExpr">ConcatExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> (","
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExprSingle" id=
"prod-xquery-ExprSingle"></a>[<small>34</small>]&#160;&#160;&#160;</td>
<td><code>ExprSingle</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FLWORExpr">FLWORExpr</a><br />
| <a href="#prod-xquery-QuantifiedExpr">QuantifiedExpr</a><br />
| <a href="#prod-xquery-TypeswitchExpr">TypeswitchExpr</a><br />
| <a href="#prod-xquery-IfExpr">IfExpr</a><br />
| <a href="#prod-xquery-InsertExpr">InsertExpr</a><br />
| <a href="#prod-xquery-DeleteExpr">DeleteExpr</a><br />
| <a href="#prod-xquery-RenameExpr">RenameExpr</a><br />
| <a href="#prod-xquery-ReplaceExpr">ReplaceExpr</a><br />
| <a href="#prod-xquery-TransformExpr">TransformExpr</a><br />
| <a href="#prod-xquery-BlockExpr">BlockExpr</a><br />
| <a href="#prod-xquery-AssignmentExpr">AssignmentExpr</a><br />
| <a href="#prod-xquery-ExitExpr">ExitExpr</a><br />
| <a href="#prod-xquery-WhileExpr">WhileExpr</a><br />
| <a href="#prod-xquery-OrExpr">OrExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FLWORExpr" id=
"prod-xquery-FLWORExpr"></a>[<small>35</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-FLWORExpr"></a><a href=
"#doc-xquery-FLWORExpr">FLWORExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-ForClause">ForClause</a> |
<a href="#prod-xquery-LetClause">LetClause</a>)+ <a href=
"#prod-xquery-WhereClause">WhereClause</a>? <a href=
"#prod-xquery-OrderByClause">OrderByClause</a>? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForClause" id=
"prod-xquery-ForClause"></a>[<small>36</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ForClause"></a><a href=
"#doc-xquery-ForClause">ForClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"for" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>?
<a href="#prod-xquery-PositionalVar">PositionalVar</a>? "in"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? <a href=
"#prod-xquery-PositionalVar">PositionalVar</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PositionalVar" id=
"prod-xquery-PositionalVar"></a>[<small>37</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-PositionalVar"></a><a href=
"#doc-xquery-PositionalVar">PositionalVar</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"at" "$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-LetClause" id=
"prod-xquery-LetClause"></a>[<small>38</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-LetClause"></a><a href=
"#doc-xquery-LetClause">LetClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"let" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhereClause" id=
"prod-xquery-WhereClause"></a>[<small>39</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-WhereClause"></a><a href=
"#doc-xquery-WhereClause">WhereClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"where" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderByClause" id=
"prod-xquery-OrderByClause"></a>[<small>40</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OrderByClause"></a><a href=
"#doc-xquery-OrderByClause">OrderByClause</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(("order" "by") | ("stable" "order" "by")) <a href=
"#prod-xquery-OrderSpecList">OrderSpecList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderSpecList" id=
"prod-xquery-OrderSpecList"></a>[<small>41</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OrderSpecList"></a><a href=
"#doc-xquery-OrderSpecList">OrderSpecList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-OrderSpec">OrderSpec</a> (","
<a href="#prod-xquery-OrderSpec">OrderSpec</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderSpec" id=
"prod-xquery-OrderSpec"></a>[<small>42</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OrderSpec"></a><a href=
"#doc-xquery-OrderSpec">OrderSpec</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ExprSingle">ExprSingle</a> <a href=
"#prod-xquery-OrderModifier">OrderModifier</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderModifier" id=
"prod-xquery-OrderModifier"></a>[<small>43</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-OrderModifier"></a><a href=
"#doc-xquery-OrderModifier">OrderModifier</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("ascending" | "descending")? ("empty" ("greatest" |
"least"))? ("collation" <a href=
"#prod-xquery-URILiteral">URILiteral</a>)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuantifiedExpr" id=
"prod-xquery-QuantifiedExpr"></a>[<small>44</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-QuantifiedExpr"></a><a href=
"#doc-xquery-QuantifiedExpr">QuantifiedExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("some" | "every") "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," "$" <a href=
"#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? "in" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "satisfies" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeswitchExpr" id=
"prod-xquery-TypeswitchExpr"></a>[<small>45</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-TypeswitchExpr"></a><a href=
"#doc-xquery-TypeswitchExpr">TypeswitchExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"typeswitch" "(" <a href="#prod-xquery-Expr">Expr</a> ")"
<a href="#prod-xquery-CaseClause">CaseClause</a>+ "default" ("$"
<a href="#prod-xquery-VarName">VarName</a>)? "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CaseClause" id=
"prod-xquery-CaseClause"></a>[<small>46</small>]&#160;&#160;&#160;</td>
<td><code>CaseClause</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"case" ("$" <a href="#prod-xquery-VarName">VarName</a>
"as")? <a href="#prod-xquery-SequenceType">SequenceType</a>
"return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IfExpr" id=
"prod-xquery-IfExpr"></a>[<small>47</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-IfExpr"></a><a href=
"#doc-xquery-IfExpr">IfExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"if" "(" <a href="#prod-xquery-Expr">Expr</a> ")" "then"
<a href="#prod-xquery-ExprSingle">ExprSingle</a> "else" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrExpr" id=
"prod-xquery-OrExpr"></a>[<small>48</small>]&#160;&#160;&#160;</td>
<td><code>OrExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AndExpr">AndExpr</a> ( "or"
<a href="#prod-xquery-AndExpr">AndExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AndExpr" id=
"prod-xquery-AndExpr"></a>[<small>49</small>]&#160;&#160;&#160;</td>
<td><code>AndExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ComparisonExpr">ComparisonExpr</a>
( "and" <a href="#prod-xquery-ComparisonExpr">ComparisonExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ComparisonExpr" id=
"prod-xquery-ComparisonExpr"></a>[<small>50</small>]&#160;&#160;&#160;</td>
<td><code>ComparisonExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-RangeExpr">RangeExpr</a> (
(<a href="#prod-xquery-ValueComp">ValueComp</a><br />
| <a href="#prod-xquery-GeneralComp">GeneralComp</a><br />
| <a href="#prod-xquery-NodeComp">NodeComp</a>) <a href=
"#prod-xquery-RangeExpr">RangeExpr</a> )?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RangeExpr" id=
"prod-xquery-RangeExpr"></a>[<small>51</small>]&#160;&#160;&#160;</td>
<td><code>RangeExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AdditiveExpr">AdditiveExpr</a> (
"to" <a href="#prod-xquery-AdditiveExpr">AdditiveExpr</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AdditiveExpr" id=
"prod-xquery-AdditiveExpr"></a>[<small>52</small>]&#160;&#160;&#160;</td>
<td><code>AdditiveExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-MultiplicativeExpr">MultiplicativeExpr</a> ( ("+" |
"-") <a href=
"#prod-xquery-MultiplicativeExpr">MultiplicativeExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-MultiplicativeExpr" id=
"prod-xquery-MultiplicativeExpr"></a>[<small>53</small>]&#160;&#160;&#160;</td>
<td><code>MultiplicativeExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-UnionExpr">UnionExpr</a> ( ("*" |
"div" | "idiv" | "mod") <a href=
"#prod-xquery-UnionExpr">UnionExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnionExpr" id=
"prod-xquery-UnionExpr"></a>[<small>54</small>]&#160;&#160;&#160;</td>
<td><code>UnionExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-IntersectExceptExpr">IntersectExceptExpr</a> (
("union" | "|") <a href=
"#prod-xquery-IntersectExceptExpr">IntersectExceptExpr</a>
)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IntersectExceptExpr" id=
"prod-xquery-IntersectExceptExpr"></a>[<small>55</small>]&#160;&#160;&#160;</td>
<td><code>IntersectExceptExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-InstanceofExpr">InstanceofExpr</a>
( ("intersect" | "except") <a href=
"#prod-xquery-InstanceofExpr">InstanceofExpr</a> )*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InstanceofExpr" id=
"prod-xquery-InstanceofExpr"></a>[<small>56</small>]&#160;&#160;&#160;</td>
<td><code>InstanceofExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-TreatExpr">TreatExpr</a> (
"instance" "of" <a href=
"#prod-xquery-SequenceType">SequenceType</a> )?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TreatExpr" id=
"prod-xquery-TreatExpr"></a>[<small>57</small>]&#160;&#160;&#160;</td>
<td><code>TreatExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CastableExpr">CastableExpr</a> (
"treat" "as" <a href="#prod-xquery-SequenceType">SequenceType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CastableExpr" id=
"prod-xquery-CastableExpr"></a>[<small>58</small>]&#160;&#160;&#160;</td>
<td><code>CastableExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-CastExpr">CastExpr</a> ( "castable"
"as" <a href="#prod-xquery-SingleType">SingleType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CastExpr" id=
"prod-xquery-CastExpr"></a>[<small>59</small>]&#160;&#160;&#160;</td>
<td><code>CastExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-UnaryExpr">UnaryExpr</a> ( "cast"
"as" <a href="#prod-xquery-SingleType">SingleType</a>
)?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnaryExpr" id=
"prod-xquery-UnaryExpr"></a>[<small>60</small>]&#160;&#160;&#160;</td>
<td><code>UnaryExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("-" | "+")* <a href=
"#prod-xquery-ValueExpr">ValueExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValueExpr" id=
"prod-xquery-ValueExpr"></a>[<small>61</small>]&#160;&#160;&#160;</td>
<td><code>ValueExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ValidateExpr">ValidateExpr</a> |
<a href="#prod-xquery-PathExpr">PathExpr</a> | <a href=
"#prod-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-GeneralComp" id=
"prod-xquery-GeneralComp"></a>[<small>62</small>]&#160;&#160;&#160;</td>
<td><code>GeneralComp</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"=" | "!=" | "&lt;" | "&lt;=" | "&gt;" |
"&gt;="</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValueComp" id=
"prod-xquery-ValueComp"></a>[<small>63</small>]&#160;&#160;&#160;</td>
<td><code>ValueComp</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"eq" | "ne" | "lt" | "le" | "gt" | "ge"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NodeComp" id=
"prod-xquery-NodeComp"></a>[<small>64</small>]&#160;&#160;&#160;</td>
<td><code>NodeComp</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"is" | "&lt;&lt;" | "&gt;&gt;"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValidateExpr" id=
"prod-xquery-ValidateExpr"></a>[<small>65</small>]&#160;&#160;&#160;</td>
<td><code>ValidateExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"validate" <a href=
"#prod-xquery-ValidationMode">ValidationMode</a>? "{" <a href=
"#prod-xquery-Expr">Expr</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ValidationMode" id=
"prod-xquery-ValidationMode"></a>[<small>66</small>]&#160;&#160;&#160;</td>
<td><code>ValidationMode</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"lax" | "strict"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExtensionExpr" id=
"prod-xquery-ExtensionExpr"></a>[<small>67</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ExtensionExpr"></a><a href=
"#doc-xquery-ExtensionExpr">ExtensionExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Pragma">Pragma</a>+ "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Pragma" id=
"prod-xquery-Pragma"></a>[<small>68</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-Pragma"></a><a href=
"#doc-xquery-Pragma">Pragma</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"(#" <a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-QName">QName</a> (<a href="#prod-xquery-S">S</a>
<a href="#prod-xquery-PragmaContents">PragmaContents</a>)?
"#)"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PragmaContents" id=
"prod-xquery-PragmaContents"></a>[<small>69</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-PragmaContents"></a><a href=
"#doc-xquery-PragmaContents">PragmaContents</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '#)'
Char*))</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PathExpr" id=
"prod-xquery-PathExpr"></a>[<small>70</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-PathExpr"></a><a href=
"#doc-xquery-PathExpr">PathExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("/" <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a>?)<br />
| ("//" <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a>)<br />
| <a href=
"#prod-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-leading-lone-slash">gn:
leading-lone-slash</a><sup><small>XQ</small></sup></span>
*/</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RelativePathExpr" id=
"prod-xquery-RelativePathExpr"></a>[<small>71</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-RelativePathExpr"></a><a href=
"#doc-xquery-RelativePathExpr">RelativePathExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-StepExpr">StepExpr</a> (("/" |
"//") <a href="#prod-xquery-StepExpr">StepExpr</a>)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-StepExpr" id=
"prod-xquery-StepExpr"></a>[<small>72</small>]&#160;&#160;&#160;</td>
<td><code>StepExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-FilterExpr">FilterExpr</a> |
<a href="#prod-xquery-AxisStep">AxisStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AxisStep" id=
"prod-xquery-AxisStep"></a>[<small>73</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-AxisStep"></a><a href=
"#doc-xquery-AxisStep">AxisStep</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-ReverseStep">ReverseStep</a> |
<a href="#prod-xquery-ForwardStep">ForwardStep</a>) <a href=
"#prod-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForwardStep" id=
"prod-xquery-ForwardStep"></a>[<small>74</small>]&#160;&#160;&#160;</td>
<td><code>ForwardStep</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-ForwardAxis">ForwardAxis</a>
<a href="#prod-xquery-NodeTest">NodeTest</a>) | <a href=
"#prod-xquery-AbbrevForwardStep">AbbrevForwardStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ForwardAxis" id=
"prod-xquery-ForwardAxis"></a>[<small>75</small>]&#160;&#160;&#160;</td>
<td><code>ForwardAxis</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("child" "::")<br />
| ("descendant" "::")<br />
| ("attribute" "::")<br />
| ("self" "::")<br />
| ("descendant-or-self" "::")<br />
| ("following-sibling" "::")<br />
| ("following" "::")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AbbrevForwardStep" id=
"prod-xquery-AbbrevForwardStep"></a>[<small>76</small>]&#160;&#160;&#160;</td>
<td><code>AbbrevForwardStep</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"@"? <a href=
"#prod-xquery-NodeTest">NodeTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReverseStep" id=
"prod-xquery-ReverseStep"></a>[<small>77</small>]&#160;&#160;&#160;</td>
<td><code>ReverseStep</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-ReverseAxis">ReverseAxis</a>
<a href="#prod-xquery-NodeTest">NodeTest</a>) | <a href=
"#prod-xquery-AbbrevReverseStep">AbbrevReverseStep</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReverseAxis" id=
"prod-xquery-ReverseAxis"></a>[<small>78</small>]&#160;&#160;&#160;</td>
<td><code>ReverseAxis</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("parent" "::")<br />
| ("ancestor" "::")<br />
| ("preceding-sibling" "::")<br />
| ("preceding" "::")<br />
| ("ancestor-or-self" "::")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AbbrevReverseStep" id=
"prod-xquery-AbbrevReverseStep"></a>[<small>79</small>]&#160;&#160;&#160;</td>
<td><code>AbbrevReverseStep</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>".."</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NodeTest" id=
"prod-xquery-NodeTest"></a>[<small>80</small>]&#160;&#160;&#160;</td>
<td><code>NodeTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-KindTest">KindTest</a> | <a href=
"#prod-xquery-NameTest">NameTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NameTest" id=
"prod-xquery-NameTest"></a>[<small>81</small>]&#160;&#160;&#160;</td>
<td><code>NameTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a> | <a href=
"#prod-xquery-Wildcard">Wildcard</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Wildcard" id=
"prod-xquery-Wildcard"></a>[<small>82</small>]&#160;&#160;&#160;</td>
<td><code>Wildcard</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"*"<br />
| (<a href="#prod-xquery-NCName">NCName</a> ":" "*")<br />
| ("*" ":" <a href="#prod-xquery-NCName">NCName</a>)</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FilterExpr" id=
"prod-xquery-FilterExpr"></a>[<small>83</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-FilterExpr"></a><a href=
"#doc-xquery-FilterExpr">FilterExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-PrimaryExpr">PrimaryExpr</a>
<a href="#prod-xquery-PredicateList">PredicateList</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PredicateList" id=
"prod-xquery-PredicateList"></a>[<small>84</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-PredicateList"></a><a href=
"#doc-xquery-PredicateList">PredicateList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-Predicate">Predicate</a>*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Predicate" id=
"prod-xquery-Predicate"></a>[<small>85</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-Predicate"></a><a href=
"#doc-xquery-Predicate">Predicate</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"[" <a href="#prod-xquery-Expr">Expr</a> "]"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PrimaryExpr" id=
"prod-xquery-PrimaryExpr"></a>[<small>86</small>]&#160;&#160;&#160;</td>
<td><code>PrimaryExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Literal">Literal</a> | <a href=
"#prod-xquery-VarRef">VarRef</a> | <a href=
"#prod-xquery-ParenthesizedExpr">ParenthesizedExpr</a> | <a href=
"#prod-xquery-ContextItemExpr">ContextItemExpr</a> | <a href=
"#prod-xquery-FunctionCall">FunctionCall</a> | <a href=
"#prod-xquery-OrderedExpr">OrderedExpr</a> | <a href=
"#prod-xquery-UnorderedExpr">UnorderedExpr</a> | <a href=
"#prod-xquery-Constructor">Constructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Literal" id=
"prod-xquery-Literal"></a>[<small>87</small>]&#160;&#160;&#160;</td>
<td><code>Literal</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-NumericLiteral">NumericLiteral</a>
| <a href=
"#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NumericLiteral" id=
"prod-xquery-NumericLiteral"></a>[<small>88</small>]&#160;&#160;&#160;</td>
<td><code>NumericLiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-IntegerLiteral">IntegerLiteral</a>
| <a href="#prod-xquery-DecimalLiteral">DecimalLiteral</a> |
<a href="#prod-xquery-DoubleLiteral">DoubleLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarRef" id=
"prod-xquery-VarRef"></a>[<small>89</small>]&#160;&#160;&#160;</td>
<td><code>VarRef</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"$" <a href=
"#prod-xquery-VarName">VarName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-VarName" id=
"prod-xquery-VarName"></a>[<small>90</small>]&#160;&#160;&#160;</td>
<td><code>VarName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ParenthesizedExpr" id=
"prod-xquery-ParenthesizedExpr"></a>[<small>91</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ParenthesizedExpr"></a><a href=
"#doc-xquery-ParenthesizedExpr">ParenthesizedExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"(" <a href="#prod-xquery-Expr">Expr</a>? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ContextItemExpr" id=
"prod-xquery-ContextItemExpr"></a>[<small>92</small>]&#160;&#160;&#160;</td>
<td><code>ContextItemExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"."</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OrderedExpr" id=
"prod-xquery-OrderedExpr"></a>[<small>93</small>]&#160;&#160;&#160;</td>
<td><code>OrderedExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"ordered" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-UnorderedExpr" id=
"prod-xquery-UnorderedExpr"></a>[<small>94</small>]&#160;&#160;&#160;</td>
<td><code>UnorderedExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"unordered" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-FunctionCall" id=
"prod-xquery-FunctionCall"></a>[<small>95</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-FunctionCall"></a><a href=
"#doc-xquery-FunctionCall">FunctionCall</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a> "(" (<a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ("," <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)*)? ")"</code></td>
<td><i>/* <a href="#parse-note-sx-reserved-function-names">gn:
sx-reserved-function-names</a> */</i></td>
</tr>
<tr>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-parens">gn:
parens</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Constructor" id=
"prod-xquery-Constructor"></a>[<small>96</small>]&#160;&#160;&#160;</td>
<td><code>Constructor</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-DirectConstructor">DirectConstructor</a><br />
| <a href=
"#prod-xquery-ComputedConstructor">ComputedConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirectConstructor" id=
"prod-xquery-DirectConstructor"></a>[<small>97</small>]&#160;&#160;&#160;</td>
<td><code>DirectConstructor</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-DirElemConstructor">DirElemConstructor</a><br />
| <a href=
"#prod-xquery-DirCommentConstructor">DirCommentConstructor</a><br />
| <a href=
"#prod-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirElemConstructor" id=
"prod-xquery-DirElemConstructor"></a>[<small>98</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-DirElemConstructor"></a><a href=
"#doc-xquery-DirElemConstructor">DirElemConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-DirAttributeList">DirAttributeList</a> ("/&gt;" |
("&gt;" <a href="#prod-xquery-DirElemContent">DirElemContent</a>*
"&lt;/" <a href="#prod-xquery-QName">QName</a> <a href=
"#prod-xquery-S">S</a>? "&gt;"))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirAttributeList" id=
"prod-xquery-DirAttributeList"></a>[<small>99</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-DirAttributeList"></a><a href=
"#doc-xquery-DirAttributeList">DirAttributeList</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-S">S</a> (<a href=
"#prod-xquery-QName">QName</a> <a href="#prod-xquery-S">S</a>? "="
<a href="#prod-xquery-S">S</a>? <a href=
"#prod-xquery-DirAttributeValue">DirAttributeValue</a>)?)*</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirAttributeValue" id=
"prod-xquery-DirAttributeValue"></a>[<small>100</small>]&#160;&#160;&#160;</td>
<td><code>DirAttributeValue</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>('"' (<a href="#prod-xquery-EscapeQuot">EscapeQuot</a> |
<a href=
"#prod-xquery-QuotAttrValueContent">QuotAttrValueContent</a>)*
'"')<br />
| ("'" (<a href="#prod-xquery-EscapeApos">EscapeApos</a> | <a href=
"#prod-xquery-AposAttrValueContent">AposAttrValueContent</a>)*
"'")</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuotAttrValueContent" id=
"prod-xquery-QuotAttrValueContent"></a>[<small>101</small>]&#160;&#160;&#160;</td>
<td><code>QuotAttrValueContent</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-QuotAttrContentChar">QuotAttrContentChar</a><br />
| <a href=
"#prod-xquery-CommonContent">CommonContent</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AposAttrValueContent" id=
"prod-xquery-AposAttrValueContent"></a>[<small>102</small>]&#160;&#160;&#160;</td>
<td><code>AposAttrValueContent</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-AposAttrContentChar">AposAttrContentChar</a><br />
| <a href=
"#prod-xquery-CommonContent">CommonContent</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirElemContent" id=
"prod-xquery-DirElemContent"></a>[<small>103</small>]&#160;&#160;&#160;</td>
<td><code>DirElemContent</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-DirectConstructor">DirectConstructor</a><br />
| <a href="#prod-xquery-CDataSection">CDataSection</a><br />
| <a href="#prod-xquery-CommonContent">CommonContent</a><br />
| <a href=
"#prod-xquery-ElementContentChar">ElementContentChar</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommonContent" id=
"prod-xquery-CommonContent"></a>[<small>104</small>]&#160;&#160;&#160;</td>
<td><code>CommonContent</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a> |
<a href="#prod-xquery-CharRef">CharRef</a> | "{{" | "}}" | <a href=
"#prod-xquery-EnclosedExpr">EnclosedExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirCommentConstructor" id=
"prod-xquery-DirCommentConstructor"></a>[<small>105</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-DirCommentConstructor"></a><a href=
"#doc-xquery-DirCommentConstructor">DirCommentConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;!--" <a href=
"#prod-xquery-DirCommentContents">DirCommentContents</a>
"--&gt;"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirCommentContents" id=
"prod-xquery-DirCommentContents"></a>[<small>106</small>]&#160;&#160;&#160;</td>
<td><code>DirCommentContents</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>((<a href="#prod-xquery-Char">Char</a> - '-') | ('-'
(<a href="#prod-xquery-Char">Char</a> - '-')))*</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirPIConstructor" id=
"prod-xquery-DirPIConstructor"></a>[<small>107</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-DirPIConstructor"></a><a href=
"#doc-xquery-DirPIConstructor">DirPIConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;?" <a href="#prod-xquery-PITarget">PITarget</a>
(<a href="#prod-xquery-S">S</a> <a href=
"#prod-xquery-DirPIContents">DirPIContents</a>)?
"?&gt;"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DirPIContents" id=
"prod-xquery-DirPIContents"></a>[<small>108</small>]&#160;&#160;&#160;</td>
<td><code>DirPIContents</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* '?&gt;'
Char*))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CDataSection" id=
"prod-xquery-CDataSection"></a>[<small>109</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CDataSection"></a><a href=
"#doc-xquery-CDataSection">CDataSection</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&lt;![CDATA[" <a href=
"#prod-xquery-CDataSectionContents">CDataSectionContents</a>
"]]&gt;"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CDataSectionContents" id=
"prod-xquery-CDataSectionContents"></a>[<small>110</small>]&#160;&#160;&#160;</td>
<td><code>CDataSectionContents</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-Char">Char</a>* - (Char* ']]&gt;'
Char*))</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ComputedConstructor" id=
"prod-xquery-ComputedConstructor"></a>[<small>111</small>]&#160;&#160;&#160;</td>
<td><code>ComputedConstructor</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-CompDocConstructor">CompDocConstructor</a><br />
| <a href=
"#prod-xquery-CompElemConstructor">CompElemConstructor</a><br />
| <a href=
"#prod-xquery-CompAttrConstructor">CompAttrConstructor</a><br />
| <a href=
"#prod-xquery-CompTextConstructor">CompTextConstructor</a><br />
| <a href=
"#prod-xquery-CompCommentConstructor">CompCommentConstructor</a><br />
| <a href=
"#prod-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompDocConstructor" id=
"prod-xquery-CompDocConstructor"></a>[<small>112</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompDocConstructor"></a><a href=
"#doc-xquery-CompDocConstructor">CompDocConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"document" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompElemConstructor" id=
"prod-xquery-CompElemConstructor"></a>[<small>113</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompElemConstructor"></a><a href=
"#doc-xquery-CompElemConstructor">CompElemConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"element" (<a href="#prod-xquery-QName">QName</a> | ("{"
<a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-ContentExpr">ContentExpr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ContentExpr" id=
"prod-xquery-ContentExpr"></a>[<small>114</small>]&#160;&#160;&#160;</td>
<td><code>ContentExpr</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompAttrConstructor" id=
"prod-xquery-CompAttrConstructor"></a>[<small>115</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompAttrConstructor"></a><a href=
"#doc-xquery-CompAttrConstructor">CompAttrConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"attribute" (<a href="#prod-xquery-QName">QName</a> |
("{" <a href="#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompTextConstructor" id=
"prod-xquery-CompTextConstructor"></a>[<small>116</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompTextConstructor"></a><a href=
"#doc-xquery-CompTextConstructor">CompTextConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"text" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompCommentConstructor" id=
"prod-xquery-CompCommentConstructor"></a>[<small>117</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompCommentConstructor"></a><a href=
"#doc-xquery-CompCommentConstructor">CompCommentConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"comment" "{" <a href="#prod-xquery-Expr">Expr</a>
"}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CompPIConstructor" id=
"prod-xquery-CompPIConstructor"></a>[<small>118</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-CompPIConstructor"></a><a href=
"#doc-xquery-CompPIConstructor">CompPIConstructor</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"processing-instruction" (<a href=
"#prod-xquery-NCName">NCName</a> | ("{" <a href=
"#prod-xquery-Expr">Expr</a> "}")) "{" <a href=
"#prod-xquery-Expr">Expr</a>? "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SingleType" id=
"prod-xquery-SingleType"></a>[<small>119</small>]&#160;&#160;&#160;</td>
<td><code>SingleType</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AtomicType">AtomicType</a>
"?"?</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeDeclaration" id=
"prod-xquery-TypeDeclaration"></a>[<small>120</small>]&#160;&#160;&#160;</td>
<td><code>TypeDeclaration</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"as" <a href=
"#prod-xquery-SequenceType">SequenceType</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SequenceType" id=
"prod-xquery-SequenceType"></a>[<small>121</small>]&#160;&#160;&#160;</td>
<td><code>SequenceType</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("empty-sequence" "(" ")")<br />
| (<a href="#prod-xquery-ItemType">ItemType</a> <a href=
"#prod-xquery-OccurrenceIndicator">OccurrenceIndicator</a>?)</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-OccurrenceIndicator" id=
"prod-xquery-OccurrenceIndicator"></a>[<small>122</small>]&#160;&#160;&#160;</td>
<td><code>OccurrenceIndicator</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"?" | "*" | "+"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-occurrence-indicators">gn:
occurrence-indicators</a><sup><small>XQ</small></sup></span>
*/</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ItemType" id=
"prod-xquery-ItemType"></a>[<small>123</small>]&#160;&#160;&#160;</td>
<td><code>ItemType</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-KindTest">KindTest</a> | ("item"
"(" ")") | <a href=
"#prod-xquery-AtomicType">AtomicType</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AtomicType" id=
"prod-xquery-AtomicType"></a>[<small>124</small>]&#160;&#160;&#160;</td>
<td><code>AtomicType</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-KindTest" id=
"prod-xquery-KindTest"></a>[<small>125</small>]&#160;&#160;&#160;</td>
<td><code>KindTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-DocumentTest">DocumentTest</a><br />
| <a href="#prod-xquery-ElementTest">ElementTest</a><br />
| <a href="#prod-xquery-AttributeTest">AttributeTest</a><br />
| <a href=
"#prod-xquery-SchemaElementTest">SchemaElementTest</a><br />
| <a href=
"#prod-xquery-SchemaAttributeTest">SchemaAttributeTest</a><br />
| <a href="#prod-xquery-PITest">PITest</a><br />
| <a href="#prod-xquery-CommentTest">CommentTest</a><br />
| <a href="#prod-xquery-TextTest">TextTest</a><br />
| <a href="#prod-xquery-AnyKindTest">AnyKindTest</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AnyKindTest" id=
"prod-xquery-AnyKindTest"></a>[<small>126</small>]&#160;&#160;&#160;</td>
<td><code>AnyKindTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"node" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DocumentTest" id=
"prod-xquery-DocumentTest"></a>[<small>127</small>]&#160;&#160;&#160;</td>
<td><code>DocumentTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"document-node" "(" (<a href=
"#prod-xquery-ElementTest">ElementTest</a> | <a href=
"#prod-xquery-SchemaElementTest">SchemaElementTest</a>)?
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TextTest" id=
"prod-xquery-TextTest"></a>[<small>128</small>]&#160;&#160;&#160;</td>
<td><code>TextTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"text" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommentTest" id=
"prod-xquery-CommentTest"></a>[<small>129</small>]&#160;&#160;&#160;</td>
<td><code>CommentTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"comment" "(" ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PITest" id=
"prod-xquery-PITest"></a>[<small>130</small>]&#160;&#160;&#160;</td>
<td><code>PITest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"processing-instruction" "(" (<a href=
"#prod-xquery-NCName">NCName</a> | <a href=
"#prod-xquery-StringLiteral">StringLiteral</a>)? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeTest" id=
"prod-xquery-AttributeTest"></a>[<small>131</small>]&#160;&#160;&#160;</td>
<td><code>AttributeTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"attribute" "(" (<a href=
"#prod-xquery-AttribNameOrWildcard">AttribNameOrWildcard</a> (","
<a href="#prod-xquery-TypeName">TypeName</a>)?)? ")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttribNameOrWildcard" id=
"prod-xquery-AttribNameOrWildcard"></a>[<small>132</small>]&#160;&#160;&#160;</td>
<td><code>AttribNameOrWildcard</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-AttributeName">AttributeName</a> |
"*"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaAttributeTest" id=
"prod-xquery-SchemaAttributeTest"></a>[<small>133</small>]&#160;&#160;&#160;</td>
<td><code>SchemaAttributeTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"schema-attribute" "(" <a href=
"#prod-xquery-AttributeDeclaration">AttributeDeclaration</a>
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeDeclaration" id=
"prod-xquery-AttributeDeclaration"></a>[<small>134</small>]&#160;&#160;&#160;</td>
<td><code>AttributeDeclaration</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-AttributeName">AttributeName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementTest" id=
"prod-xquery-ElementTest"></a>[<small>135</small>]&#160;&#160;&#160;</td>
<td><code>ElementTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"element" "(" (<a href=
"#prod-xquery-ElementNameOrWildcard">ElementNameOrWildcard</a> (","
<a href="#prod-xquery-TypeName">TypeName</a> "?"?)?)?
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementNameOrWildcard" id=
"prod-xquery-ElementNameOrWildcard"></a>[<small>136</small>]&#160;&#160;&#160;</td>
<td><code>ElementNameOrWildcard</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-ElementName">ElementName</a> |
"*"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SchemaElementTest" id=
"prod-xquery-SchemaElementTest"></a>[<small>137</small>]&#160;&#160;&#160;</td>
<td><code>SchemaElementTest</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"schema-element" "(" <a href=
"#prod-xquery-ElementDeclaration">ElementDeclaration</a>
")"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementDeclaration" id=
"prod-xquery-ElementDeclaration"></a>[<small>138</small>]&#160;&#160;&#160;</td>
<td><code>ElementDeclaration</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ElementName">ElementName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AttributeName" id=
"prod-xquery-AttributeName"></a>[<small>139</small>]&#160;&#160;&#160;</td>
<td><code>AttributeName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementName" id=
"prod-xquery-ElementName"></a>[<small>140</small>]&#160;&#160;&#160;</td>
<td><code>ElementName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TypeName" id=
"prod-xquery-TypeName"></a>[<small>141</small>]&#160;&#160;&#160;</td>
<td><code>TypeName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-QName">QName</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-URILiteral" id=
"prod-xquery-URILiteral"></a>[<small>142</small>]&#160;&#160;&#160;</td>
<td><code>URILiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-StringLiteral">StringLiteral</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RevalidationDecl" id=
"prod-xquery-RevalidationDecl"></a>[<small>143</small>]&#160;&#160;&#160;</td>
<td><code>RevalidationDecl</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "revalidation" ("strict" | "lax" |
"skip")</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InsertExprTargetChoice" id=
"prod-xquery-InsertExprTargetChoice"></a>[<small>144</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-InsertExprTargetChoice"></a><a href=
"#doc-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(("as" ("first" | "last"))? "into")<br />
| "after"<br />
| "before"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-InsertExpr" id=
"prod-xquery-InsertExpr"></a>[<small>145</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-InsertExpr"></a><a href=
"#doc-xquery-InsertExpr">InsertExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"insert" ("node" | "nodes") <a href=
"#prod-xquery-SourceExpr">SourceExpr</a> <a href=
"#prod-xquery-InsertExprTargetChoice">InsertExprTargetChoice</a>
<a href="#prod-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DeleteExpr" id=
"prod-xquery-DeleteExpr"></a>[<small>146</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-DeleteExpr"></a><a href=
"#doc-xquery-DeleteExpr">DeleteExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"delete" ("node" | "nodes") <a href=
"#prod-xquery-TargetExpr">TargetExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ReplaceExpr" id=
"prod-xquery-ReplaceExpr"></a>[<small>147</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ReplaceExpr"></a><a href=
"#doc-xquery-ReplaceExpr">ReplaceExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"replace" ("value" "of")? "node" <a href=
"#prod-xquery-TargetExpr">TargetExpr</a> "with" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-RenameExpr" id=
"prod-xquery-RenameExpr"></a>[<small>148</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-RenameExpr"></a><a href=
"#doc-xquery-RenameExpr">RenameExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"rename" "node" <a href=
"#prod-xquery-TargetExpr">TargetExpr</a> "as" <a href=
"#prod-xquery-NewNameExpr">NewNameExpr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-SourceExpr" id=
"prod-xquery-SourceExpr"></a>[<small>149</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-SourceExpr"></a><a href=
"#doc-xquery-SourceExpr">SourceExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TargetExpr" id=
"prod-xquery-TargetExpr"></a>[<small>150</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-TargetExpr"></a><a href=
"#doc-xquery-TargetExpr">TargetExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NewNameExpr" id=
"prod-xquery-NewNameExpr"></a>[<small>151</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-NewNameExpr"></a><a href=
"#doc-xquery-NewNameExpr">NewNameExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-TransformExpr" id=
"prod-xquery-TransformExpr"></a>[<small>152</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-TransformExpr"></a><a href=
"#doc-xquery-TransformExpr">TransformExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"copy" "$" <a href="#prod-xquery-VarName">VarName</a>
":=" <a href="#prod-xquery-ExprSingle">ExprSingle</a> ("," "$"
<a href="#prod-xquery-VarName">VarName</a> ":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)* "modify" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> "return" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockExpr" id=
"prod-xquery-BlockExpr"></a>[<small>153</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-BlockExpr"></a><a href=
"#doc-xquery-BlockExpr">BlockExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"block" <a href=
"#prod-xquery-Block">Block</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Block" id=
"prod-xquery-Block"></a>[<small>154</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-Block"></a><a href=
"#doc-xquery-Block">Block</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"{" <a href="#prod-xquery-BlockDecls">BlockDecls</a>
<a href="#prod-xquery-BlockBody">BlockBody</a> "}"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockDecls" id=
"prod-xquery-BlockDecls"></a>[<small>155</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-BlockDecls"></a><a href=
"#doc-xquery-BlockDecls">BlockDecls</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-BlockVarDecl">BlockVarDecl</a>
";")*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockVarDecl" id=
"prod-xquery-BlockVarDecl"></a>[<small>156</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-BlockVarDecl"></a><a href=
"#doc-xquery-BlockVarDecl">BlockVarDecl</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"declare" "$" <a href="#prod-xquery-VarName">VarName</a>
<a href="#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a>)? ("," "$"
<a href="#prod-xquery-VarName">VarName</a> <a href=
"#prod-xquery-TypeDeclaration">TypeDeclaration</a>? (":=" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a>)?)*</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-BlockBody" id=
"prod-xquery-BlockBody"></a>[<small>157</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-BlockBody"></a><a href=
"#doc-xquery-BlockBody">BlockBody</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Expr">Expr</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AssignmentExpr" id=
"prod-xquery-AssignmentExpr"></a>[<small>158</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-AssignmentExpr"></a><a href=
"#doc-xquery-AssignmentExpr">AssignmentExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"$" <a href="#prod-xquery-VarName">VarName</a> ":="
<a href="#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ExitExpr" id=
"prod-xquery-ExitExpr"></a>[<small>159</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-ExitExpr"></a><a href=
"#doc-xquery-ExitExpr">ExitExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"exit" "returning" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhileExpr" id=
"prod-xquery-WhileExpr"></a>[<small>160</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-WhileExpr"></a><a href=
"#doc-xquery-WhileExpr">WhileExpr</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"while" "(" <a href=
"#prod-xquery-ExprSingle">ExprSingle</a> ")" <a href=
"#prod-xquery-WhileBody">WhileBody</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-WhileBody" id=
"prod-xquery-WhileBody"></a>[<small>161</small>]&#160;&#160;&#160;</td>
<td><code><a href="#doc-xquery-WhileBody"></a><a href=
"#doc-xquery-WhileBody">WhileBody</a></code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Block">Block</a></code></td>
</tr>
</tbody>
</table>
<div class="div2">
<h3><a name="id-terminal-symbols" id="id-terminal-symbols"></a>A.1
Terminal Symbols</h3>
<h5><a name="d7e5434" id="d7e5434"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-IntegerLiteral" id=
"prod-xquery-IntegerLiteral"></a>[<small>162</small>]&#160;&#160;&#160;</td>
<td><code>IntegerLiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Digits">Digits</a></code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DecimalLiteral" id=
"prod-xquery-DecimalLiteral"></a>[<small>163</small>]&#160;&#160;&#160;</td>
<td><code>DecimalLiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>("." <a href="#prod-xquery-Digits">Digits</a>) |
(<a href="#prod-xquery-Digits">Digits</a> "." [0-9]*)</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-DoubleLiteral" id=
"prod-xquery-DoubleLiteral"></a>[<small>164</small>]&#160;&#160;&#160;</td>
<td><code>DoubleLiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(("." <a href="#prod-xquery-Digits">Digits</a>) |
(<a href="#prod-xquery-Digits">Digits</a> ("." [0-9]*)?)) [eE]
[+-]? <a href="#prod-xquery-Digits">Digits</a></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-StringLiteral" id=
"prod-xquery-StringLiteral"></a>[<small>165</small>]&#160;&#160;&#160;</td>
<td><code>StringLiteral</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>('"' (<a href=
"#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a> |
<a href="#prod-xquery-CharRef">CharRef</a> | <a href=
"#prod-xquery-EscapeQuot">EscapeQuot</a> | [^"&amp;])* '"') | ("'"
(<a href="#prod-xquery-PredefinedEntityRef">PredefinedEntityRef</a>
| <a href="#prod-xquery-CharRef">CharRef</a> | <a href=
"#prod-xquery-EscapeApos">EscapeApos</a> | [^'&amp;])*
"'")</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PredefinedEntityRef" id=
"prod-xquery-PredefinedEntityRef"></a>[<small>166</small>]&#160;&#160;&#160;</td>
<td><code>PredefinedEntityRef</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"&amp;" ("lt" | "gt" | "amp" | "quot" | "apos")
";"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EscapeQuot" id=
"prod-xquery-EscapeQuot"></a>[<small>167</small>]&#160;&#160;&#160;</td>
<td><code>EscapeQuot</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>'""'</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-EscapeApos" id=
"prod-xquery-EscapeApos"></a>[<small>168</small>]&#160;&#160;&#160;</td>
<td><code>EscapeApos</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"''"</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-ElementContentChar" id=
"prod-xquery-ElementContentChar"></a>[<small>169</small>]&#160;&#160;&#160;</td>
<td><code>ElementContentChar</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Char">Char</a> -
[{}&lt;&amp;]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QuotAttrContentChar" id=
"prod-xquery-QuotAttrContentChar"></a>[<small>170</small>]&#160;&#160;&#160;</td>
<td><code>QuotAttrContentChar</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Char">Char</a> -
["{}&lt;&amp;]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-AposAttrContentChar" id=
"prod-xquery-AposAttrContentChar"></a>[<small>171</small>]&#160;&#160;&#160;</td>
<td><code>AposAttrContentChar</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href="#prod-xquery-Char">Char</a> -
['{}&lt;&amp;]</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Comment" id=
"prod-xquery-Comment"></a>[<small>172</small>]&#160;&#160;&#160;</td>
<td><code>Comment</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>"(:" (<a href=
"#prod-xquery-CommentContents">CommentContents</a> | <a href=
"#prod-xquery-Comment">Comment</a>)* ":)"</code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#ws-explicit">ws:
explicit</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
<tr>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-comments">gn:
comments</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-PITarget" id=
"prod-xquery-PITarget"></a>[<small>173</small>]&#160;&#160;&#160;</td>
<td><code>PITarget</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-PITarget">[http://www.w3.org/TR/REC-xml#NT-PITarget]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CharRef" id=
"prod-xquery-CharRef"></a>[<small>174</small>]&#160;&#160;&#160;</td>
<td><code>CharRef</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-CharRef">[http://www.w3.org/TR/REC-xml#NT-CharRef]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-QName" id=
"prod-xquery-QName"></a>[<small>175</small>]&#160;&#160;&#160;</td>
<td><code>QName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml-names/#NT-QName">[http://www.w3.org/TR/REC-xml-names/#NT-QName]</a><sup><small>Names</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-NCName" id=
"prod-xquery-NCName"></a>[<small>176</small>]&#160;&#160;&#160;</td>
<td><code>NCName</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml-names/#NT-NCName">[http://www.w3.org/TR/REC-xml-names/#NT-NCName]</a><sup><small>Names</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-S" id=
"prod-xquery-S"></a>[<small>177</small>]&#160;&#160;&#160;</td>
<td><code>S</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-S">[http://www.w3.org/TR/REC-xml#NT-S]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Char" id=
"prod-xquery-Char"></a>[<small>178</small>]&#160;&#160;&#160;</td>
<td><code>Char</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code><a href=
"http://www.w3.org/TR/REC-xml#NT-Char">[http://www.w3.org/TR/REC-xml#NT-Char]</a><sup><small>XML</small></sup></code></td>
<td><i>/* <span><a href=
"http://www.w3.org/TR/xquery#parse-note-xml-version">gn:
xml-version</a><sup><small>XQ</small></sup></span> */</i></td>
</tr>
</tbody>
</table>
<p>The following symbols are used only in the definition of
terminal symbols; they are not terminal symbols in the grammar of
<a href="#id-grammar"><b>[A EBNF for XQuery 1.0 Grammar with
Scripting Extensions]</b></a>.</p>
<h5><a name="d7e5626" id="d7e5626"></a></h5>
<table class="scrap" summary="Scrap">
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-Digits" id=
"prod-xquery-Digits"></a>[<small>179</small>]&#160;&#160;&#160;</td>
<td><code>Digits</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>[0-9]+</code></td>
</tr>
</tbody>
<tbody>
<tr valign="baseline">
<td><a name="prod-xquery-CommentContents" id=
"prod-xquery-CommentContents"></a>[<small>180</small>]&#160;&#160;&#160;</td>
<td><code>CommentContents</code></td>
<td>&#160;&#160;&#160;::=&#160;&#160;&#160;</td>
<td><code>(<a href="#prod-xquery-Char">Char</a>+ - (Char* ('(:' |
':)') Char*))</code></td>
</tr>
</tbody>
</table>
</div>
<div class="div2">
<h3><a name="id-extra-grammatical-constraints" id=
"id-extra-grammatical-constraints"></a>A.2 Extra-grammatical
Constraints</h3>
<p>This section contains XQuery SX specific constraints on the EBNF
productions, which are required to parse legal sentences. The notes
below are referenced from the right side of the production, with
the notation: <em>/* gn: &lt;id&gt; */</em>.</p>
<div class="constraint">
<p class="prefix"><a name="parse-note-sx-reserved-function-names"
id="parse-note-sx-reserved-function-names"></a><b>Constraint:
sx-reserved-function-names</b></p>
<p>XQuery SX adds the term "while" to the list of names in <a href=
"http://www.w3.org/TR/xquery#id-reserved-fn-names">Section A.3
Reserved Function Names</a><sup><small>XQ</small></sup>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>This is a backwards incompatibility with <a href="#XQ10">[XQuery
1.0]</a>.</p>
</div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="id-xqsx-xqueryx" id="id-xqsx-xqueryx"></a>B XML Syntax
(XQueryX) for XQuery Scripting Extension 1.0</h2>
<p><a href="#XQX10">[XML Syntax for XQuery 1.0]</a> defines an XML
representation of <a href="#XQ10">[XQuery 1.0]</a>. <a href=
"#ScriptingRequirements">[XQuery Scripting Requirements]</a> states
"The syntax for updates MAY have more than one syntax binding. One
syntax MUST be convenient for humans to read and write. One syntax
MUST be expressed in XML in a way that reflects the underlying
structure of the operations." This appendix specifies an XML Schema
that defines the XML representation of XQuery Scripting Extension
1.0 by representing the abstract syntax found in <a href=
"#id-grammar"><b>[A EBNF for XQuery 1.0 Grammar with Scripting
Extensions]</b></a>. This XML representation for XQuery Scripting
Extension 1.0 integrates with the XML representation for XQuery 1.0
and that for the XQuery Update Facility 1.0.</p>
<p>The XML Schema specified in this appendix accomplishes its
integration by importing the XML Schema defined for XQueryX in
<a href="#XQueryUpdate">[XQuery Update Facility]</a>, incorporating
all of its type and element definitions. It then extends that
schema by adding definitions of new types and elements in a
namespace belonging to the XQuery Scripting Extension 1.0
specification.</p>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-schema" id=
"id-xqsx-xqueryx-schema"></a>B.1 Schema</h3>
<p>This section specifies the XML Schema that defines the complex
types and elements for XQueryX in support of XQuery Scripting
Extension 1.0, including changes to the prolog and the addition of
several new expressions. It also specifies a second XML Schema that
redefines an element defined in XQueryX 1.0. Copies of these two
schemata can be found at <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd">http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd</a>.
and <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd">
http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd</a>.
Please note that the content of these schemata are subject to
change at any time before this document is published as a
Recommendation.</p>
<div class="exampleInner">
<pre>
&lt;xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10"
targetNamespace="http://www.w3.org/2008/xquery-sx-10"
elementFormDefault="qualified"
attributeFormDefault="unqualified"&gt;
&lt;!-- Initial creation 2008-03-01: Jim Melton --&gt;
&lt;!-- Added FunctionDecl redefinition 2008-03-11: Jim Melton --&gt;
&lt;!-- Updated to new WD grammar 2008-11-25: Jim Melton --&gt;
&lt;!-- Reviewed, cleaned, corrections 2009-08-17: Jim Melton --&gt;
&lt;!-- Updated to recent grammar changes 2010-02-15: Jim Melton --&gt;
&lt;xsd:import namespace="http://www.w3.org/2005/XQueryX"
schemaLocation="http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx-redef.xsd"/&gt;
&lt;!-- Declare new type for constant declarations --&gt;
&lt;!-- Corresponds to the following grammar productions: --&gt;
&lt;!-- VarDecl ::= "declare" ([un]assignable variable) --&gt;
&lt;!-- "$" QName TypeDeclaration? --&gt;
&lt;!-- ((":=" ExprSingle) | "external") --&gt;
&lt;xsd:complexType name="constDecl"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="constName" type="xqx:QName"/&gt;
&lt;xsd:element ref="typeDeclaration" minOccurs="0"/&gt;
&lt;xsd:choice&gt;
&lt;xsd:element name="varValue" type="exprWrapper"/&gt;
&lt;xsd:element name="external" type="emptyContent"/&gt;
&lt;/xsd:choice&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="constDecl" type="xqxsx:constDecl"
substitutionGroup="xqx:prologPartTwoItem"/&gt;
&lt;!-- Create substitution grp for scripting extension exprs --&gt;
&lt;xsd:complexType name="expr"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="xqx:expr"/&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;!-- Make scripting extension subst grp part of expr grp --&gt;
&lt;xsd:element name="expr" type="xqxsx:expr" abstract="true"
substitutionGroup="xqx:expr"/&gt;
&lt;!-- AssignmentExpr: --&gt;
&lt;!-- AssignmentExpr ::= "$" VarName ":=" ExprSingle --&gt;
&lt;xsd:complexType name="assignmentExpr"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="xqxsx:expr"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element ref="xqx:positionalVariableBinding"/&gt;
&lt;xsd:element name="assignedExpr" type="xqx:exprWrapper"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:extension&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="assignmentExpr" type="xqxsx:assignmentExpr"
substitutionGroup="xqxsx:expr"/&gt;
&lt;!-- Block (1 of 3): --&gt;
&lt;!-- BlockExpr ::= "block" Block --&gt;
&lt;!-- Block ::= "{" BlockDecls BlockBody "}" --&gt;
&lt;!-- BlockDecls ::= (BlockVarDecl ";")* --&gt;
&lt;xsd:complexType name="block"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="xqxsx:expr"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element ref="xqxsx:blockVarDecl"
minOccurs="0" maxOccurs="unbounded"/&gt;
&lt;xsd:element ref="xqxsx:blockBody"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:extension&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="block" type="xqxsx:block"
substitutionGroup="xqxsx:expr"/&gt;
&lt;!-- Block (2 of 3): --&gt;
&lt;!-- BlockVarDecl ::= --&gt;
&lt;!-- "declare" "$" VarName TypeDeclaration? --&gt;
&lt;!-- (":=" ExprSingle)? --&gt;
&lt;!-- ("," "$" VarName TypeDeclaration? --&gt;
&lt;!-- (":=" ExprSingle)? )* --&gt;
&lt;xsd:complexType name="blockVarDecl"&gt;
&lt;xsd:sequence minOccurs="1" maxOccurs="unbounded"&gt;
&lt;xsd:element name="varName" type="xqx:QName"/&gt;
&lt;xsd:element ref="xqx:typeDeclaration" minOccurs="0"/&gt;
&lt;xsd:element name="varValue" type="xqx:exprWrapper"
minOccurs="0"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="blockVarDecl" type="xqxsx:blockVarDecl"/&gt;
&lt;!-- Block (3 of 3): --&gt;
&lt;!-- BlockBody ::= Expr --&gt;
&lt;xsd:complexType name="blockBody"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="blockExpr" type="xqx:exprWrapper"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="blockBody" type="xqxsx:blockBody"/&gt;
&lt;!-- ExitExpr: --&gt;
&lt;!-- ExitExpr ::= "exit" "returning" ExprSingle --&gt;
&lt;xsd:element name="exitExpr" type="xqxsx:expr"
substitutionGroup="xqxsx:expr"/&gt;
&lt;!-- WhileExpr: --&gt;
&lt;!-- WhileExpr ::= "while" "(" ExprSingle ")" WhileBody --&gt;
&lt;!-- WhileBody ::= Block --&gt;
&lt;xsd:complexType name="whileExpr"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="xqxsx:expr"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="whileTest" type="xqx:exprWrapper"/&gt;
&lt;xsd:element ref="xqxsx:block"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:extension&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="whileExpr" type="xqxsx:whileExpr"
substitutionGroup="xqxsx:expr"/&gt;
&lt;!-- ApplyExpr: --&gt;
&lt;!-- ApplyExpr ::= (ConcatExpr ";")+ --&gt;
&lt;xsd:complexType name="applyExpr"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="xqxsx:expr"&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="applyExprs" maxOccurs="unbounded"&gt;
&lt;xsd:complexType&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element ref="xqxsx:expr" maxOccurs="unbounded"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;/xsd:element&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:extension&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;xsd:element name="applyExpr" type="xqxsx:applyExpr"
substitutionGroup="xqxsx:expr"/&gt;
&lt;/xsd:schema&gt;
&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/2005/XQueryX"
targetNamespace="http://www.w3.org/2005/XQueryX"
elementFormDefault="qualified" attributeFormDefault="qualified"&gt;
&lt;!-- Redefine one or more components of the XQueryX XML Schema --&gt;
&lt;!-- The redefinition starts with XQuery Update Facility 1.0 --&gt;
&lt;!-- XQueryX instead of XQueryX 1.0 --&gt;
&lt;xsd:redefine schemaLocation="http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx-redef.xsd"&gt;
&lt;!-- Redefine the functionDecl complex type --&gt;
&lt;xsd:complexType name="functionDecl"&gt;
&lt;xsd:complexContent&gt;
&lt;xsd:extension base="functionDecl"&gt;
&lt;xsd:attribute name="simpleFunction"
type="xsd:boolean" default="true"/&gt;
&lt;xsd:attribute name="sequentialFunction"
type="xsd:boolean" default="false"/&gt;
&lt;xsd:attribute name="sequentialFunction"
type="xsd:boolean" default="false"/&gt;
&lt;/xsd:extension&gt;
&lt;/xsd:complexContent&gt;
&lt;/xsd:complexType&gt;
&lt;/xsd:redefine&gt;
&lt;/xsd:schema&gt;
</pre></div>
</div>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-stylesheet" id=
"id-xqsx-xqueryx-stylesheet"></a>B.2 Stylesheet</h3>
<p>This section specifies the XSLT stylesheet that defines the
semantics of XQueryX in support of XQuery Scripting Extension 1.0.
It imports the XSLT stylesheet defined in <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>, and provides
additional templates that define the semantics of the XQueryX
representation of XQuery Scripting Extension 1.0 by transforming
that XQueryX representation into the human readable syntax of
XQuery Scripting Extension 1.0. A copy of this stylesheet is
located at <a href=
"http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsl">http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsl</a>.
Please note that the content of this stylesheet is subject to
change at any time before this document is published as a
Recommendation.</p>
<div class="exampleInner">
<pre>
&lt;xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10"&gt;
&lt;!-- Initial creation 2008-03-01: Jim Melton --&gt;
&lt;!-- Reviewed, cleaned, corrections 2009-08-17: Jim Melton --&gt;
&lt;!-- Updated to recent grammar changes 2010-02-15: Jim Melton --&gt;
&lt;xsl:import href="http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsl"/&gt;
&lt;!-- constDecl --&gt;
&lt;!-- 2010-02-15: "constant" is now "unassignable variable" --&gt;
&lt;xsl:template match="xqxsx:constDecl"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:text&gt;declare unassignable variable &lt;/xsl:text&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:constName"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- Over-ride the template for varDecl in XQueryX.xsd --&gt;
&lt;!-- 2010-02-15: "variable" is now "assignable variable" --&gt;
&lt;xsl:template match="xqx:varDecl" priority="200"&gt;
&lt;xsl:text&gt;declare assignable variable &lt;/xsl:text&gt;
&lt;xsl:value-of select="$DOLLAR"/&gt;
&lt;xsl:apply-templates select="xqx:varName"/&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;xsl:if test="xqx:external"&gt;
&lt;xsl:text&gt; external &lt;/xsl:text&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test="xqx:varValue"&gt;
&lt;xsl:value-of select="$ASSIGN"/&gt;
&lt;xsl:apply-templates select="xqx:varValue"/&gt;
&lt;/xsl:if&gt;
&lt;/xsl:template&gt;
&lt;!-- assignmentExpr --&gt;
&lt;!-- 2010-02-15: Remove 'set' keyword --&gt;
&lt;xsl:template match="xqxsx:assignmentExpr"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:apply-templates select="xqx:positionalVariableBinding"/&gt;
&lt;xsl:text&gt; := &lt;/xsl:text&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:assignedExpr"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- block --&gt;
&lt;!-- 2010-02-15: Added 'block' keyword --&gt;
&lt;xsl:template match="xqxsx:block"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:text&gt;block &lt;/xsl:text&gt;
&lt;xsl:value-of select="$LBRACE"/&gt;
&lt;xsl:value-of select="$SPACE"/&gt;
&lt;xsl:apply-templates/&gt;
&lt;xsl:value-of select="$SPACE"/&gt;
&lt;xsl:value-of select="$RBRACE"/&gt;
&lt;xsl:value-of select="$SPACE"/&gt;
&lt;/xsl:template&gt;
&lt;!-- blockVarDecl --&gt;
&lt;xsl:template match="xqxsx:blockVarDecl[position()=1 and position()=last()]"&gt;
&lt;xsl:text&gt;declare &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varName"/&gt;
&lt;xsl:if test="xqx:typeDeclaration"&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test="xqxsx:varValue"&gt;
&lt;xsl:text&gt; := &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varValue"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:value-of select="$SEMICOLON"/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:blockVarDecl[position()=1 and position()!=last()]"&gt;
&lt;xsl:text&gt;declare &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varName"/&gt;
&lt;xsl:if test="xqx:typeDeclaration"&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test="xqxsx:varValue"&gt;
&lt;xsl:text&gt; := &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varValue"/&gt;
&lt;/xsl:if&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:blockVarDecl[position()&gt;1 and position()&amp;lt;last()]"&gt;
&lt;xsl:value-of select="$COMMA"/&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:apply-templates select="xqxsx:varName"/&gt;
&lt;xsl:if test="xqx:typeDeclaration"&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test="xqxsx:varValue"&gt;
&lt;xsl:text&gt; := &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varValue"/&gt;
&lt;/xsl:if&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:blockVarDecl[position()&gt;1 and position()=last()]"&gt;
&lt;xsl:value-of select="$COMMA"/&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:apply-templates select="xqxsx:varName"/&gt;
&lt;xsl:if test="xqx:typeDeclaration"&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test="xqxsx:varValue"&gt;
&lt;xsl:text&gt; := &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqxsx:varValue"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:value-of select="$SEMICOLON"/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:varName"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:varValue"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- blockBody --&gt;
&lt;xsl:template match="xqxsx:blockBody"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:blockExpr"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- exitExpr --&gt;
&lt;xsl:template match="xqxsx:exitExpr"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:text&gt;exit returning &lt;/xsl:text&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- whileExpr --&gt;
&lt;xsl:template match="xqxsx:whileExpr"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:text&gt;while &lt;/xsl:text&gt;
&lt;xsl:value-of select="$LPAREN"/&gt;
&lt;xsl:value-of select="$SPACE"/&gt;
&lt;xsl:apply-templates select="xqxsx:whileTest"/&gt;
&lt;xsl:value-of select="$SPACE"/&gt;
&lt;xsl:value-of select="$RPAREN"/&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:apply-templates select="xqxsx:block"/&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:whileTest"&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;
&lt;!-- applyExpr --&gt;
&lt;xsl:template match="xqxsx:applyExpr"&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;xsl:apply-templates select="xqxsx:applyExprs"/&gt;
&lt;xsl:value-of select="$NEWLINE"/&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match="xqxsx:applyExprs"&gt;
&lt;xsl:apply-templates/&gt;
&lt;xsl:value-of select="$SEMICOLON"/&gt;
&lt;/xsl:template&gt;
&lt;!-- Over-ride the template for functionDecl in XQuery --&gt;
&lt;!-- Update Facility xquery-update-10-xqueryx-redef.xsd --&gt;
&lt;xsl:template match="xqx:functionDecl" priority="200"&gt;
&lt;xsl:text&gt;declare &lt;/xsl:text&gt;
&lt;xsl:choose&gt;
&lt;xsl:when test="@xqx:updatingFunction and
@xqx:updatingFunction = 'true'"&gt;
&lt;xsl:text&gt;updating &lt;/xsl:text&gt;
&lt;/xsl:when&gt;
&lt;xsl:when test="@xqx:sequentialFunction and
@xqx:sequentialFunction = 'true'"&gt;
&lt;xsl:text&gt;sequential &lt;/xsl:text&gt;
&lt;/xsl:when&gt;
&lt;xsl:otherwise&gt;
&lt;xsl:text&gt;simple &lt;/xsl:text&gt;
&lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
&lt;xsl:text&gt;function &lt;/xsl:text&gt;
&lt;xsl:apply-templates select="xqx:functionName"/&gt;
&lt;xsl:apply-templates select="xqx:paramList"/&gt;
&lt;xsl:apply-templates select="xqx:typeDeclaration"/&gt;
&lt;xsl:apply-templates select="xqx:functionBody"/&gt;
&lt;xsl:if test="xqx:externalDefinition"&gt;
&lt;xsl:text&gt; external &lt;/xsl:text&gt;
&lt;/xsl:if&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre></div>
</div>
<div class="div2">
<h3><a name="id-xqsx-xqueryx-examples" id=
"id-xqsx-xqueryx-examples"></a>B.3 Example</h3>
<p>The following example is based on the data and queries in the
use cases in <a href="#ScriptingUseCases">[XQuery Scripting Use
Cases]</a>. In this example, we show the English description of the
query, the XQuery Scripting Extension solution given in <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a>, an XQueryX
solution, and the XQuery Update Facility expression that results
from applying the Update Facility XQueryX-to-XQuery Update Facility
transformation defined by the stylesheet in <a href=
"#id-xqsx-xqueryx-stylesheet"><b>[B.2 Stylesheet]</b></a> to the
Scripting Extension XQueryX solution. The XQuery Scripting
Extension expression that is produced is presented only as a
sanity-check—the intent of the stylesheet is not to recreate the
original XQuery expression, but to produce <em>a</em> valid XQuery
expression with the same semantics. The semantics of the Scripting
Extension XQueryX solution are determined by the semantics of the
XQuery Update Facility expression that results from that
transformation. The "correctness" of that transformation is
determined by asking the following the question: Can some Scripting
Extension XQueryX processor QX process some Scripting Extension
XQueryX document D1 to produce results R1, after which the
stylesheet is used to translate D1 into an XQuery Scripting
Extension expression E1 that, when processed by some XQuery
Scripting Extension processor Q, produces results R2 that are
equivalent (under some meaningful definition of "equivalent") to
results R1?</p>
<p>Comparison of the results of the Scripting Extension
XQueryX-to-XQuery Scripting Extension transformation given in this
document with the XQuery Scripting Extension solutions in <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a> may be
helpful in evaluating the correctness of the Update Facility
XQueryX solution in each example.</p>
<p>The XQuery Scripting Extension Use Cases solution given for each
example is provided only to assist readers of this document in
understanding the Scripting Extension XQueryX solution. There is no
intent to imply that this document specifies a "compilation" or
"transformation" of XQuery Scripting Extension syntax into
Scripting Extension XQueryX syntax.</p>
<p>In the following example, note that path expressions are
expanded to show their structure. Also, note that the prefix syntax
for binary operators like "and" makes the precedence explicit. In
general, humans find it easier to read an XML representation that
does not expand path expressions, but it is less convenient for
programmatic representation and manipulation. XQueryX is designed
as a language that is convenient for production and modification by
software, and not as a convenient syntax for humans to read and
write.</p>
<p>Finally, please note that white space, including new lines, have
been added to some of the Scripting Extension XQueryX documents and
XQuery Scripting Extension expressions for readability. That
additional white space is not produced by the Scripting Extension
XQueryX-to-XQuery Scripting Extension transformation.</p>
<p>This example is based on query "Q2" from <a href=
"#ScriptingUseCases">[XQuery Scripting Use Cases]</a>, use case
"R": "Scripting Relational Data":</p>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-xq-rep" id=
"id-xqsx-xqueryx-xq-rep"></a>B.3.1 XQuery Representation</h4>
<div class="exampleInner">
<pre>
let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid
let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid)
let $newbid := $topbid * 1.1
return
if($newbid &lt;= 240) then {
insert nodes
&lt;bid_tuple&gt;
&lt;userid&gt;{ data($uid) }&lt;/userid&gt;
&lt;itemno&gt;1002&lt;/itemno&gt;
&lt;bid&gt;{ $newbid }&lt;/bid&gt;
&lt;bid_date&gt;1999-03-03&lt;/bid_date&gt;
&lt;/bid_tuple&gt;
into doc("bids.xml")/bids;
exit returning &lt;new_bid&gt;{ $newbid }&lt;/new_bid&gt;;
} else {
exit returning &lt;top_bid&gt;{ $topbid }&lt;/top_bid&gt;;
}
</pre></div>
</div>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-xqx-rep" id=
"id-xqsx-xqueryx-xqx-rep"></a>B.3.2 XQueryX Representation</h4>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0"?&gt;
&lt;!--
let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid
let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid)
let $newbid := $topbid * 1.1
return
if($newbid &lt;= 240) then {
insert nodes
&lt;bid_tuple&gt;
&lt;userid&gt;{ data($uid) }&lt;/userid&gt;
&lt;itemno&gt;1002&lt;/itemno&gt;
&lt;bid&gt;{ $newbid }&lt;/bid&gt;
&lt;bid_date&gt;1999-03-03&lt;/bid_date&gt;
&lt;/bid_tuple&gt;
into doc("bids.xml")/bids;
exit returning &lt;new_bid&gt;{ $newbid }&lt;/new_bid&gt;;
} else {
exit returning &lt;top_bid&gt;{ $topbid }&lt;/top_bid&gt;;
}
--&gt;
&lt;xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:xqxuf="http://www.w3.org/2007/xquery-update-10"
xmlns:xqxsx="http://www.w3.org/2008/xquery-sx-10"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/XQueryX
http://www.w3.org/2005/XQueryX/xqueryx.xsd
http://www.w3.org/2007/xquery-update-10
http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd
http://www.w3.org/2008/xquery-sx-10
http://www.w3.org/2008/xquery-sx-10/xquery-sx-10-xqueryx.xsd"&gt;
&lt;xqx:queryBody&gt;
&lt;xqx:flworExpr&gt;
&lt;!-- let $uid := doc("users.xml")/users/user_tuple[name = "Roger Smith"]/userid --&gt;
&lt;xqx:letClause&gt;
&lt;xqx:letClauseItem&gt;
&lt;xqx:typedVariableBinding&gt;
&lt;xqx:varName&gt;uid&lt;/xqx:varName&gt;
&lt;/xqx:typedVariableBinding&gt;
&lt;xqx:letExpr&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:filterExpr&gt;
&lt;xqx:functionCallExpr&gt;
&lt;xqx:functionName
xqx:prefix="fn"&gt;doc&lt;/xqx:functionName&gt;
&lt;xqx:arguments&gt;
&lt;xqx:stringConstantExpr&gt;
&lt;xqx:value&gt;users.xml&lt;/xqx:value&gt;
&lt;/xqx:stringConstantExpr&gt;
&lt;/xqx:arguments&gt;
&lt;/xqx:functionCallExpr&gt;
&lt;/xqx:filterExpr&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;users&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;user-tuple&lt;/xqx:nameTest&gt;
&lt;xqx:predicates&gt;
&lt;xqx:equalOp&gt;
&lt;xqx:firstOperand&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;name&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqx:firstOperand&gt;
&lt;xqx:secondOperand&gt;
&lt;xqx:stringConstantExpr&gt;
&lt;xqx:value&gt;Roger Smith&lt;/xqx:value&gt;
&lt;/xqx:stringConstantExpr&gt;
&lt;/xqx:secondOperand&gt;
&lt;/xqx:equalOp&gt;
&lt;/xqx:predicates&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;userid&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqx:letExpr&gt;
&lt;/xqx:letClauseItem&gt;
&lt;/xqx:letClause&gt;
&lt;!-- let $topbid := max(doc("bids.xml")/bids/bid_tuple[itemno = 1007]/bid) --&gt;
&lt;xqx:letClause&gt;
&lt;xqx:letClauseItem&gt;
&lt;xqx:typedVariableBinding&gt;
&lt;xqx:varName&gt;topbid&lt;/xqx:varName&gt;
&lt;/xqx:typedVariableBinding&gt;
&lt;xqx:letExpr&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:filterExpr&gt;
&lt;xqx:functionCallExpr&gt;
&lt;xqx:functionName
xqx:prefix="fn"&gt;max&lt;/xqx:functionName&gt;
&lt;xqx:arguments&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:filterExpr&gt;
&lt;xqx:functionCallExpr&gt;
&lt;xqx:functionName
xqx:prefix="fn"&gt;doc&lt;/xqx:functionName&gt;
&lt;xqx:arguments&gt;
&lt;xqx:stringConstantExpr&gt;
&lt;xqx:value&gt;bids.xml&lt;/xqx:value&gt;
&lt;/xqx:stringConstantExpr&gt;
&lt;/xqx:arguments&gt;
&lt;/xqx:functionCallExpr&gt;
&lt;/xqx:filterExpr&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;bids&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;bid-tuple&lt;/xqx:nameTest&gt;
&lt;xqx:predicates&gt;
&lt;xqx:equalOp&gt;
&lt;xqx:firstOperand&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;itemno&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqx:firstOperand&gt;
&lt;xqx:secondOperand&gt;
&lt;xqx:integerConstantExpr&gt;
&lt;xqx:value&gt;1007&lt;/xqx:value&gt;
&lt;/xqx:integerConstantExpr&gt;
&lt;/xqx:secondOperand&gt;
&lt;/xqx:equalOp&gt;
&lt;/xqx:predicates&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;bid&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqx:arguments&gt;
&lt;/xqx:functionCallExpr&gt;
&lt;/xqx:filterExpr&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqx:letExpr&gt;
&lt;/xqx:letClauseItem&gt;
&lt;/xqx:letClause&gt;
&lt;!-- let $newbid := $topbid * 1.1 --&gt;
&lt;xqx:letClause&gt;
&lt;xqx:letClauseItem&gt;
&lt;xqx:typedVariableBinding&gt;
&lt;xqx:varName&gt;newbid&lt;/xqx:varName&gt;
&lt;/xqx:typedVariableBinding&gt;
&lt;xqx:letExpr&gt;
&lt;xqx:multiplyOp&gt;
&lt;xqx:firstOperand&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;topbid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:firstOperand&gt;
&lt;xqx:secondOperand&gt;
&lt;xqx:decimalConstantExpr&gt;
&lt;xqx:value&gt;1.1&lt;/xqx:value&gt;
&lt;/xqx:decimalConstantExpr&gt;
&lt;/xqx:secondOperand&gt;
&lt;/xqx:multiplyOp&gt;
&lt;/xqx:letExpr&gt;
&lt;/xqx:letClauseItem&gt;
&lt;/xqx:letClause&gt;
&lt;!-- return --&gt;
&lt;xqx:returnClause&gt;
&lt;!-- if($newbid &lt;= 240) --&gt;
&lt;xqx:ifThenElseExpr&gt;
&lt;xqx:ifClause&gt;
&lt;xqx:lessThanOrEqualOp&gt;
&lt;xqx:firstOperand&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;newbid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:firstOperand&gt;
&lt;xqx:secondOperand&gt;
&lt;xqx:integerConstantExpr&gt;
&lt;xqx:value&gt;240&lt;/xqx:value&gt;
&lt;/xqx:integerConstantExpr&gt;
&lt;/xqx:secondOperand&gt;
&lt;/xqx:lessThanOrEqualOp&gt;
&lt;/xqx:ifClause&gt;
&lt;!-- then { --&gt;
&lt;xqx:thenClause&gt;
&lt;xqxsx:block&gt;
&lt;xqxsx:blockBody&gt;
&lt;xqxsx:blockExpr&gt;
&lt;!-- insert nodes --&gt;
&lt;xqxuf:insertExpr&gt;
&lt;xqxuf:sourceExpr&gt;
&lt;!-- &lt;bid_tuple&gt; --&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;bid_tuple&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;!-- &lt;userid&gt;{ data($uid) }&lt;/userid&gt; --&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;userid&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:functionCallExpr&gt;
&lt;xqx:functionName
xqx:prefix="fn"&gt;data&lt;/xqx:functionName&gt;
&lt;xqx:arguments&gt;
&lt;xqx:exprList&gt;
&lt;xqx:expr&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;uid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:expr&gt;
&lt;/xqx:exprList&gt;
&lt;/xqx:arguments&gt;
&lt;/xqx:functionCallExpr&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;!-- &lt;itemno&gt;1002&lt;/itemno&gt; --&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;itemno&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:integerConstantExpr&gt;
&lt;xqx:value&gt;1002&lt;/xqx:value&gt;
&lt;/xqx:integerConstantExpr&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;!-- &lt;bid&gt;{ $newbid }&lt;/bid&gt; --&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;bid&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;bid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;!-- &lt;bid_date&gt;1999-03-03&lt;/bid_date&gt; --&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;bid_date&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:stringConstantExpr&gt;
&lt;xqx:value&gt;1999-03-03&lt;/xqx:value&gt;
&lt;/xqx:stringConstantExpr&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;/xqxuf:sourceExpr&gt;
&lt;!-- into doc("bids.xml")/bids; --&gt;
&lt;xqxuf:insertInto/&gt;
&lt;xqxuf:targetExpr&gt;
&lt;xqx:pathExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:filterExpr&gt;
&lt;xqx:functionCallExpr&gt;
&lt;xqx:functionName
xqx:prefix="fn"&gt;doc&lt;/xqx:functionName&gt;
&lt;xqx:arguments&gt;
&lt;xqx:stringConstantExpr&gt;
&lt;xqx:value&gt;bids.xml&lt;/xqx:value&gt;
&lt;/xqx:stringConstantExpr&gt;
&lt;/xqx:arguments&gt;
&lt;/xqx:functionCallExpr&gt;
&lt;/xqx:filterExpr&gt;
&lt;/xqx:stepExpr&gt;
&lt;xqx:stepExpr&gt;
&lt;xqx:xpathAxis&gt;child&lt;/xqx:xpathAxis&gt;
&lt;xqx:nameTest&gt;bids&lt;/xqx:nameTest&gt;
&lt;/xqx:stepExpr&gt;
&lt;/xqx:pathExpr&gt;
&lt;/xqxuf:targetExpr&gt;
&lt;/xqxuf:insertExpr&gt;
&lt;/xqxsx:blockExpr&gt;
&lt;!-- exit returning &lt;new_bid&gt;{ $newbid }&lt;/new_bid&gt;; --&gt;
&lt;xqxsx:blockExpr&gt;
&lt;xqxsx:exitExpr&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;new_bid&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;newbid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;/xqxsx:exitExpr&gt;
&lt;/xqxsx:blockExpr&gt;
&lt;/xqxsx:blockBody&gt;
&lt;/xqxsx:block&gt;
&lt;/xqx:thenClause&gt;
&lt;!-- } else { --&gt;
&lt;xqx:elseClause&gt;
&lt;!-- exit returning &lt;top_bid&gt;{ $topbid }&lt;/top_bid&gt;; --&gt;
&lt;xqxsx:block&gt;
&lt;xqxsx:blockBody&gt;
&lt;xqxsx:blockExpr&gt;
&lt;xqxsx:exitExpr&gt;
&lt;xqx:elementConstructor&gt;
&lt;xqx:tagName&gt;top_bid&lt;/xqx:tagName&gt;
&lt;xqx:elementContent&gt;
&lt;xqx:varRef&gt;
&lt;xqx:name&gt;topbid&lt;/xqx:name&gt;
&lt;/xqx:varRef&gt;
&lt;/xqx:elementContent&gt;
&lt;/xqx:elementConstructor&gt;
&lt;/xqxsx:exitExpr&gt;
&lt;/xqxsx:blockExpr&gt;
&lt;/xqxsx:blockBody&gt;
&lt;/xqxsx:block&gt;
&lt;/xqx:elseClause&gt;
&lt;/xqx:ifThenElseExpr&gt;
&lt;/xqx:returnClause&gt;
&lt;!-- } --&gt;
&lt;/xqx:flworExpr&gt;
&lt;/xqx:queryBody&gt;
&lt;/xqx:module&gt;
</pre></div>
</div>
<div class="div3">
<h4><a name="id-xqsx-xqueryx-transformed-rep" id=
"id-xqsx-xqueryx-transformed-rep"></a>B.3.3 Transformed XQuery
Representation</h4>
<p>Application of the stylesheet in <a href=
"#id-xqsx-xqueryx-stylesheet"><b>[B.2 Stylesheet]</b></a> to the
Update Facility XQueryX representation results in the following
XQuery representation:</p>
<div class="exampleInner">
<pre>
( let $uid:=fn:doc("users.xml")/child::users/
child::user-tuple[(child::name = "Roger Smith")]/
child::userid
let $topbid:=fn:max(fn:doc("bids.xml")/
child::bids/child::bid-tuple[(child::itemno = 1007)]/
child::bid)
let $newbid:=($topbid*1.1)
return
( if (($newbid &lt;= 240)) then {
insert nodes
&lt;bid_tuple&gt;
&lt;userid&gt;{fn:data($uid)}&lt;/userid&gt;
&lt;itemno&gt;{1002}&lt;/itemno&gt;
&lt;bid&gt;{$bid}&lt;/bid&gt;
&lt;bid_date&gt;{"1999-03-03"}&lt;/bid_date&gt;
&lt;/bid_tuple&gt;
into
fn:doc("bids.xml")/child::bids
exit returning &lt;new_bid&gt;{$newbid}&lt;/new_bid&gt; }
else {
exit returning &lt;top_bid&gt;{$topbid}&lt;/top_bid&gt; } )
)
</pre></div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="id-implementation-defined-items" id=
"id-implementation-defined-items"></a>C Implementation-Defined
Items</h2>
<p>The following items in this specification are
implementation-defined:</p>
<ol class="enumar">
<li>
<p>The effects of <a title="snapshot" href="#dt-snapshot">snapshot
semantics</a> on persistent storage. For example, it is
implementation-defined whether the effects of an
<code>fn:put</code> function are visible to an <code>fn:doc</code>,
<code>fn:doc-available</code>, or <code>fn:collection</code>
function executed in a subsequent <a title="snapshot" href=
"#dt-snapshot">snapshot</a>.</p>
</li>
<li>
<p>The mechanism (if any) by which the XQuery environment exchanges
parameters and results with an external function.</p>
</li>
</ol>
</div>
<div class="div1">
<h2><a name="id-references" id="id-references"></a>D
References</h2>
<dl>
<dt class="label"><span><a name="XQ10" id="XQ10"></a>XQuery
1.0</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery/">XQuery 1.0: An XML
Query Language</a>, W3C Recommendation, 23 January 2007.</div>
</dd>
<dt class="label"><span><a name="XQX10" id="XQX10"></a>XML Syntax
for XQuery 1.0</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xqueryx/">XML Syntax for XQuery
1.0</a>, W3C Recommendation, 23 January 2007.</div>
</dd>
<dt class="label"><span><a name="XDM" id="XDM"></a>XQuery Data
Model</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xpath-datamodel/">XQuery 1.0 and
XPath 2.0 Data Model (XDM)</a>, W3C Recommendation, 23 January
2007.</div>
</dd>
<dt class="label"><span><a name="FO" id="FO"></a>XQuery 1.0 and
XPath 2.0 Functions and Operators</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xpath-functions/">XQuery 1.0 and
XPath 2.0 Functions and Operators</a>, W3C Recommendation, 23
January 2007.</div>
</dd>
<dt class="label"><span><a name="XQueryUpdate" id=
"XQueryUpdate"></a>XQuery Update Facility</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-update-10/">XQuery Update
Facility 1.0</a>, W3C Candidate Recommendation, March 2008.</div>
</dd>
<dt class="label"><span><a name="ScriptingRequirements" id=
"ScriptingRequirements"></a>XQuery Scripting
Requirements</span></dt>
<dd>
<div><a href=
"http://www.w3.org/TR/xquery-sx-10-requirements/">XQuery Scripting
Extension 1.0 Requirements</a>, W3C Working Draft, 23 March
2007.</div>
</dd>
<dt class="label"><span><a name="ScriptingUseCases" id=
"ScriptingUseCases"></a>XQuery Scripting Use Cases</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-sx-10-use-cases/">XQuery
Scripting Extension 1.0 Use Cases</a>, W3C Working Draft 23 March
2007.</div>
</dd>
<dt class="label"><span><a name="XQ11" id="XQ11"></a>XQuery
1.1</span></dt>
<dd>
<div><a href="http://www.w3.org/TR/xquery-11/">XQuery 1.1: An XML
Query Language</a>, W3C Working Draft, 15 December 2009.</div>
</dd>
</dl>
</div>
<div class="div1">
<h2><a name="id-errors" id="id-errors"></a>E Error Conditions</h2>
<div class="div2">
<h3><a name="id-new-error-codes" id="id-new-error-codes"></a>E.1
New Error Codes</h3>
<dl>
<dt><a name="ERRSXST0002" id="ERRSXST0002"></a>err:SXST0002</dt>
<dd>
<p>It is a static error to mix both <a title="updating expression"
href="#dt-updating-expr">updating</a> and <a title=
"sequential expression" href="#dt-sequential-expr">sequential</a>
operands in an expression.</p>
</dd>
<dt><a name="ERRSXDY0003" id="ERRSXDY0003"></a>err:SXDY0003</dt>
<dd>
<p>It is a dynamic error if, after applying a pending update list
(using <code>upd:applyUpdates</code>), the XDM instance bound to
any in-scope variable does not match the static type of that
variable according to SequenceType matching rules.</p>
</dd>
<dt><a name="ERRSXDY0004" id="ERRSXDY0004"></a>err:SXDY0004</dt>
<dd>
<p>It is an dynamic error for an external sequential function to
return a non-empty <a title="pending update list" href=
"#dt-pul">pending update list</a>.</p>
</dd>
<dt><a name="ERRSXST0005" id="ERRSXST0005"></a>err:SXST0005</dt>
<dd>
<p>It is a static error if two or more variables declared in the
same block expression have the same expanded QName.</p>
</dd>
<dt><a name="ERRSXTY0006" id="ERRSXTY0006"></a>err:SXTY0006</dt>
<dd>
<p>A reference to a variable, other than on the left-hand side of
an assignment expression, is an error if the variable has no value
in <em>variable values</em> when the reference is evaluated.</p>
</dd>
<dt><a name="ERRSXST0007" id="ERRSXST0007"></a>err:SXST0007</dt>
<dd>
<p>The variable on the left-hand side of an assignment must have
been declared in one of the following ways:</p>
<ul>
<li>
<p>By a block variable declaration</p>
</li>
<li>
<p>As a parameter to a sequential function</p>
</li>
<li>
<p>By a variable declaration in the Prolog <span>declared as
<a title="assignable" href=
"#dt-assignable">assignable</a></span></p>
</li>
</ul>
</dd>
<dt><a name="ERRSXST0008" id="ERRSXST0008"></a>err:SXST0008</dt>
<dd>
<p>It is a static error if the body of a function violates the
category rules for it's declared category.</p>
</dd>
<dt><a name="ERRSXST0009" id="ERRSXST0009"></a>err:SXST0009</dt>
<dd>
<p>A static error is raised if the value for a
<code>xqsx:query-mode</code> option or pragma is not either
<code>sequential</code> or <code>simple</code>.</p>
</dd>
</dl>
</div>
<div class="div2">
<h3><a name="id-amended-error-codes" id=
"id-amended-error-codes"></a>E.2 Amendments to Existing Error
Codes</h3>
<dl>
<dt><a name="ERRXUST0001" id="ERRXUST0001"></a>err:XUST0001</dt>
<dd>
<p>It is a static error for an <a title="updating expression" href=
"#dt-updating-expr">updating</a> or <a title=
"sequential expression" href="#dt-sequential-expr">sequential
expression</a> to occur in the following places:</p>
<ol class="enumar">
<li>
<p>As the initializing expression of a prolog variable.</p>
</li>
<li>
<p>As a StepExpr in a RelativePathExpr when <a title="query mode"
href="#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
<li>
<p>As the primary expression or a predicate expression of a
FilterExpr or AxisStep when <a title="query mode" href=
"#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
<li>
<p>In the <code>for</code>, <code>let</code>, <code>where</code>,
or <code>order by</code> clauses of a FLWOR expression when
<a title="query mode" href="#dt-query-mode">query mode</a> is
<code>simple</code>.</p>
</li>
<li>
<p>In a quantified expression clause or as the satisfies expression
of a quantified expression when <a title="query mode" href=
"#dt-query-mode">query mode</a> is <code>simple</code>.</p>
</li>
</ol>
</dd>
</dl>
</div>
</div>
<div class="div1">
<h2><a name="id-glossary" id="id-glossary"></a>F Glossary
(Non-Normative)</h2>
<dl>
<dt><a name="GLdt-xdm-instance" id="GLdt-xdm-instance"></a>XDM
instance</dt>
<dd>
<p>An <b>XDM instance</b> is an unconstrained sequence of zero or
more nodes and/or atomic values, as defined in <a href=
"#XDM">[XQuery Data Model]</a>.</p>
</dd>
<dt><a name="GLdt-xqsx" id="GLdt-xqsx"></a>XQSX</dt>
<dd>
<p><b>XQSX</b> is an abbreviation for XQuery Scripting
Extension.</p>
</dd>
<dt><a name="GLdt-xquf" id="GLdt-xquf"></a>XQUF</dt>
<dd>
<p><b>XQUF</b> is an abbreviation for <a href=
"#XQueryUpdate">[XQuery Update Facility]</a>.</p>
</dd>
<dt><a name="GLdt-apply-expr" id="GLdt-apply-expr"></a>apply
expression</dt>
<dd>
<p>An <b>apply expression</b> is a list of semicolon-terminated
ConcatExpr productions, called operand expressions. An ApplyExpr
consisting of a single ConcatExpr with no semicolon is not an apply
expression.</p>
</dd>
<dt><a name="GLdt-assignable" id=
"GLdt-assignable"></a>assignable</dt>
<dd>
<p>Prolog variables declared as <b>assignable</b> may have their
value changed by an <a href="#id-assignment"><b>[5.3 Assignment
Expression]</b></a>.</p>
</dd>
<dt><a name="GLdt-constant" id="GLdt-constant"></a>constant</dt>
<dd>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> allows the keyword
<code>constant</code> to be used in place of <code>variable</code>
in a Prolog declaration. A variable declared in this way is called
a <b>constant</b>.</p>
</dd>
<dt><a name="GLdt-eval-order" id="GLdt-eval-order"></a>evaluation
order</dt>
<dd>
<p><a title="XQSX" href="#dt-xqsx">XQSX</a> defines an
<b>evaluation order</b> on many kinds of XQuery expressions, which
is the order that operand expressions must be evaluated in order to
determine what side-effects are visible to later expressions.</p>
</dd>
<dt><a name="GLdt-initializing-expr" id=
"GLdt-initializing-expr"></a>initializing expression</dt>
<dd>
<p>The expression on the right-hand side of a block variable
declaration is called an <b>initializing expression</b>.</p>
</dd>
<dt><a name="GLdt-pul" id="GLdt-pul"></a>pending update list</dt>
<dd>
<p>A <b>pending update list</b> is an unordered collection of
update primitives, representing node state changes that have not
yet been applied, as defined in <a href="#XQueryUpdate">[XQuery
Update Facility]</a>.</p>
</dd>
<dt><a name="GLdt-query-mode" id="GLdt-query-mode"></a>query
mode</dt>
<dd>
<p>The <b>query mode</b> governs the composability of <a title=
"updating expression" href="#dt-updating-expr">updating</a> and
<a title="sequential expression" href=
"#dt-sequential-expr">sequential expressions</a>. Valid values are
<code>sequential</code> and <code>simple</code>.</p>
</dd>
<dt><a name="GLdt-sequential-expr" id=
"GLdt-sequential-expr"></a>sequential expression</dt>
<dd>
<p>A <b>sequential expression</b> is an expression that can have
side effects other than constructing a new node or raising an
error.</p>
</dd>
<dt><a name="GLdt-sequential-function" id=
"GLdt-sequential-function"></a>sequential function</dt>
<dd>
<p>A <b>sequential function</b> is a function whose declaration
specifies the keyword <code>sequential</code>.</p>
</dd>
<dt><a name="GLdt-simple-expr" id="GLdt-simple-expr"></a>simple
expression</dt>
<dd>
<p>A <b>simple expression</b> is an expression that is neither an
<a title="updating expression" href="#dt-updating-expr">updating
expression</a> nor a <a title="sequential expression" href=
"#dt-sequential-expr">sequential expression</a>.</p>
</dd>
<dt><a name="GLdt-simple-function" id=
"GLdt-simple-function"></a>simple function</dt>
<dd>
<p>A <b>simple function</b> is a function whose declaration
specifies neither <code>updating</code> nor
<code>sequential</code>. A <a title="simple function" href=
"#dt-simple-function">simple function</a> may optionally specify
the keyword <code>simple</code>.</p>
</dd>
<dt><a name="GLdt-snapshot" id="GLdt-snapshot"></a>snapshot</dt>
<dd>
<p>A <b>snapshot</b> is a scope within which expressions are
evaluated with respect to a fixed <a title="XDM instance" href=
"#dt-xdm-instance">XDM instance</a> and updates are held
pending.</p>
</dd>
<dt><a name="GLdt-test-expr" id="GLdt-test-expr"></a>test
expression</dt>
<dd>
<p>The expression enclosed in the parentheses of a while expression
is called a <b>test expression</b>.</p>
</dd>
<dt><a name="GLdt-updating-expr" id=
"GLdt-updating-expr"></a>updating expression</dt>
<dd>
<p>An <b>updating expression</b> is an expression that can return a
non-empty <a title="pending update list" href="#dt-pul">pending
update list</a>.</p>
</dd>
<dt><a name="GLdt-updating-function" id=
"GLdt-updating-function"></a>updating function</dt>
<dd>
<p>An <b>updating function</b> is a function whose declaration
specifies the keyword <code>updating</code>.</p>
</dd>
</dl>
</div>
<div class="div1">
<h2><a name="id-revisions-log" id="id-revisions-log"></a>G Revision
Log (Non-Normative)</h2>
<p>This log records the substantive changes that have been made to
this document. Minor editorial changes are not included in this
log.</p>
<p>This document was built from files checked in on $Date:
2010/04/05 22:10:44 $.</p>
<div class="div2">
<h3><a name="id-log-20081203" id="id-log-20081203"></a>G.1 Since
the 3 December 2008 Working Draft</h3>
<ul>
<li>
<p>Changed "exit with" to "exit returning"</p>
</li>
<li>
<p>Relaxed restrictions on where sequential expressions can
occur.</p>
</li>
<li>
<p>The type of a block variable is never inferred from it's
initializing expression.</p>
</li>
<li>
<p>Removed the "set" keyword from an assignment expression.</p>
</li>
<li>
<p>Changed "variable"/"constant" to "unassignable variable" and
"assignable variable".</p>
</li>
<li>
<p>Made execution scope and snapshot scope analogous, so stable
functions can change value in subsequent snapshots.</p>
</li>
<li>
<p>Added query mode to the static context, along with an option and
pragma to change it.</p>
</li>
<li>
<p>Added error codes for all error conditions.</p>
</li>
</ul>
</div>
<div class="div2">
<h3><a name="id-log-20080328" id="id-log-20080328"></a>G.2 Since
the 28 March 2008 Working Draft</h3>
<ul>
<li>
<p>Relaxed the restrictions on where updating expressions can occur
to a superset of those allowed by <a href="#XQueryUpdate">[XQuery
Update Facility]</a>.</p>
</li>
<li>
<p>Re-check the SequenceType of bound variables after
upd:applyUpdates is invoked.</p>
</li>
<li>
<p>Added the "block" keyword to the grammer for block
expressions.</p>
</li>
<li>
<p>Removed the break and continue expressions.</p>
</li>
<li>
<p>Added the semi-colon (apply) expression to apply updates,
removing the semi-colon separated list from block expressions.</p>
</li>
<li>
<p>Added the ability to set the value of parameters to sequential
functions.</p>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>