The following definitions were extracted from XQuery 3.1 http://www.w3.org/TR/2014/CR-xquery-31-20141218/ on 15 January 2014. No sorting has been performed. Where multiple definitions occur in a paragraph, that paragraph is repeated. That is a feature, not a bug. Multiple occurrences of the same paragraph signals that any included non-normative text may apply to one or more of the definitions the paragraph contains.
Another document that incorporates the definitions from XPath 3.1, XQuery 3.1, XPath and XQuery Functions and Operators 3.1, and XQuery and XPath Data Model 3.1 deduped and in sort order is in preparation.
[Definition: XQuery 3.1 operates on the abstract, logical structure of an XML document, rather than its surface syntax. This logical structure, known as the data model, is defined in [XQuery and XPath Data Model (XDM) 3.1].]
[Definition: An XQuery 3.1 Processor processes a query according to the XQuery 3.1 specification. ] [Definition: An XQuery 3.0 Processor processes a query according to the XQuery 3.0 specification. ] [Definition: An XQuery 1.0 Processor processes a query according to the XQuery 1.0 specification. ]
[Definition: An XQuery 3.1 Processor processes a query according to the XQuery 3.1 specification. ] [Definition: An XQuery 3.0 Processor processes a query according to the XQuery 3.0 specification. ] [Definition: An XQuery 1.0 Processor processes a query according to the XQuery 1.0 specification. ]
[Definition: An XQuery 3.1 Processor processes a query according to the XQuery 3.1 specification. ] [Definition: An XQuery 3.0 Processor processes a query according to the XQuery 3.0 specification. ] [Definition: An XQuery 1.0 Processor processes a query according to the XQuery 1.0 specification. ]
[Definition: An XPath 3.0 Processor processes a query according to the XPath 3.0 specification.] [Definition: An XPath 2.0 Processor processes a query according to the XPath 2.0 specification.] [Definition: An XPath 1.0 Processor processes a query according to the XPath 1.0 specification.]
[Definition: An XPath 3.0 Processor processes a query according to the XPath 3.0 specification.] [Definition: An XPath 2.0 Processor processes a query according to the XPath 2.0 specification.] [Definition: An XPath 1.0 Processor processes a query according to the XPath 1.0 specification.]
[Definition: An XPath 3.0 Processor processes a query according to the XPath 3.0 specification.] [Definition: An XPath 2.0 Processor processes a query according to the XPath 2.0 specification.] [Definition: An XPath 1.0 Processor processes a query according to the XPath 1.0 specification.]
[Definition: Implementation-defined indicates an aspect that may differ between implementations, but must be specified by the implementor for each particular implementation.]
[Definition: Implementation-dependent indicates an aspect that may differ between implementations, is not specified by this or any W3C specification, and is not required to be specified by the implementor for any particular implementation.]
[Definition:
In the data model, a
value is always a sequence.] [Definition: A sequence is
an ordered collection of zero or more items.] [Definition: An item is either an atomic value, a
node, or a functionDM31.]
[Definition: An atomic value is a value in
the value space of an atomic type, as defined in [XML Schema 1.0] or [XML
Schema 1.1].] [Definition: A node is an instance of one of the
node kinds defined in [XQuery
and XPath Data Model (XDM) 3.1].] Each node has a unique
node identity, a typed value, and a string
value. In addition, some nodes have a name. The typed
value of a node is a sequence of zero or more atomic values.
The string value of a node is a value of type
xs:string
. The name of a node is a value of
type xs:QName
.
[Definition:
In the data model, a
value is always a sequence.] [Definition: A sequence is
an ordered collection of zero or more items.] [Definition: An item is either an atomic value, a
node, or a functionDM31.]
[Definition: An atomic value is a value in
the value space of an atomic type, as defined in [XML Schema 1.0] or [XML
Schema 1.1].] [Definition: A node is an instance of one of the
node kinds defined in [XQuery
and XPath Data Model (XDM) 3.1].] Each node has a unique
node identity, a typed value, and a string
value. In addition, some nodes have a name. The typed
value of a node is a sequence of zero or more atomic values.
The string value of a node is a value of type
xs:string
. The name of a node is a value of
type xs:QName
.
[Definition:
In the data model, a
value is always a sequence.] [Definition: A sequence is
an ordered collection of zero or more items.] [Definition: An item is either an atomic value, a
node, or a functionDM31.]
[Definition: An atomic value is a value in
the value space of an atomic type, as defined in [XML Schema 1.0] or [XML
Schema 1.1].] [Definition: A node is an instance of one of the
node kinds defined in [XQuery
and XPath Data Model (XDM) 3.1].] Each node has a unique
node identity, a typed value, and a string
value. In addition, some nodes have a name. The typed
value of a node is a sequence of zero or more atomic values.
The string value of a node is a value of type
xs:string
. The name of a node is a value of
type xs:QName
.
[Definition:
In the data model, a
value is always a sequence.] [Definition: A sequence is
an ordered collection of zero or more items.] [Definition: An item is either an atomic value, a
node, or a functionDM31.]
[Definition: An atomic value is a value in
the value space of an atomic type, as defined in [XML Schema 1.0] or [XML
Schema 1.1].] [Definition: A node is an instance of one of the
node kinds defined in [XQuery
and XPath Data Model (XDM) 3.1].] Each node has a unique
node identity, a typed value, and a string
value. In addition, some nodes have a name. The typed
value of a node is a sequence of zero or more atomic values.
The string value of a node is a value of type
xs:string
. The name of a node is a value of
type xs:QName
.
[Definition:
In the data model, a
value is always a sequence.] [Definition: A sequence is
an ordered collection of zero or more items.] [Definition: An item is either an atomic value, a
node, or a functionDM31.]
[Definition: An atomic value is a value in
the value space of an atomic type, as defined in [XML Schema 1.0] or [XML
Schema 1.1].] [Definition: A node is an instance of one of the
node kinds defined in [XQuery
and XPath Data Model (XDM) 3.1].] Each node has a unique
node identity, a typed value, and a string
value. In addition, some nodes have a name. The typed
value of a node is a sequence of zero or more atomic values.
The string value of a node is a value of type
xs:string
. The name of a node is a value of
type xs:QName
.
[Definition: A sequence containing exactly one item is called a singleton.] An item is identical to a singleton sequence containing that item. Sequences are never nested—for example, combining the values 1, (2, 3), and ( ) into a single sequence results in the sequence (1, 2, 3). [Definition: A sequence containing zero items is called an empty sequence.]
[Definition: A sequence containing exactly one item is called a singleton.] An item is identical to a singleton sequence containing that item. Sequences are never nested—for example, combining the values 1, (2, 3), and ( ) into a single sequence results in the sequence (1, 2, 3). [Definition: A sequence containing zero items is called an empty sequence.]
[Definition: The term XDM instance is used, synonymously with the term value, to denote an unconstrained sequence of items in the data model.]
Names in XQuery 3.1 can be bound to namespaces, and are based on the syntax and semantics defined in [XML Names]. [Definition: A lexical QName is a name that conforms to the syntax of [http://www.w3.org/TR/REC-xml-names/#NT-QName].] A lexical QName consists of an optional namespace prefix and a local name. If the namespace prefix is present, it is separated from the local name by a colon. A lexical QName with a prefix can be converted into an expanded QName by resolving its namespace prefix to a namespace URI, using the statically known namespaces. The semantics of a lexical QName without a prefix depend on the expression in which it is found.
[Definition: An expanded QName consists of an optional namespace URI and a local name. An expanded QName also retains its original namespace prefix (if any), to facilitate casting the expanded QName into a string.] Two expanded QNames are equal if their namespace URIs are equal and their local names are equal (even if their namespace prefixes are not equal). Namespace URIs and local names are compared on a codepoint basis, without further normalization.
Element nodes have a property called in-scope namespaces. [Definition: The in-scope namespaces property of an element node is a set of namespace bindings, each of which associates a namespace prefix with a URI.] For a given element, one namespace binding may have an empty prefix; the URI of this namespace binding is the default namespace within the scope of the element.
[Definition: Within this specification, the term URI refers to a Universal Resource Identifier as defined in [RFC3986] and extended in [RFC3987] with the new name IRI.] The term URI has been retained in preference to IRI to avoid introducing new names for concepts such as "Base URI" that are defined or referenced across the whole family of XML specifications.
[Definition: The expression context for a given expression consists of all the information that can affect the result of the expression.]
[Definition: The module context for a given module consists of all the information that is accessible to top-level expressions in the module.] The context of a top-level expression is defined based on the context of the module in which it is defined: the context of the QueryBody is the context of the main module, and the context for evaluating a function body or for a variable's initializing expression is defined based on the context of the module in which the function or variable is defined.
[Definition: The static context of an expression is the information that is available during static analysis of the expression, prior to its evaluation.] This information can be used to decide whether the expression contains a static error.
[Definition: XPath 1.0
compatibility mode. This component must be
set by all host languages that include XPath 3.0 as a subset,
indicating whether rules for compatibility with XPath 1.0 are in
effect. XQuery sets the value of this component to
false
. ]
[Definition: Statically known
namespaces. This is a mapping from prefix to namespace URI that
defines all the namespaces that are known during static processing
of a given expression.] The URI value is whitespace normalized
according to the rules for the xs:anyURI
type in
[XML Schema 1.0] or [XML Schema 1.1]. Note the difference between
in-scope namespaces, which is a
dynamic property of an element node, and statically known namespaces, which is a
static property of an expression.
[Definition: Default
element/type namespace. This is a namespace URI or absentDM31.
The namespace URI, if present, is used for any unprefixed QName
appearing in a position where an element or type name is expected.]
The URI value is whitespace normalized according to the rules for
the xs:anyURI
type in [XML
Schema 1.0] or [XML Schema 1.1].
[Definition: Default function
namespace. This is a namespace URI or absentDM31.
The namespace URI, if present, is used for any unprefixed QName
appearing in a position where a function name is expected.] The URI
value is whitespace normalized according to the rules for the
xs:anyURI
type in [XML Schema
1.0] or [XML Schema 1.1].
[Definition: In-scope schema definitions. This is a generic term for all the element declarations, attribute declarations, and schema type definitions that are in scope during static analysis of an expression.] It includes the following three parts:
[Definition: In-scope schema types. Each schema type definition is identified either by an expanded QName (for a named type) or by an implementation-dependent type identifier (for an anonymous type). The in-scope schema types include the predefined schema types described in 2.5.1 Predefined Schema Types. If the Schema Aware Feature is supported, in-scope schema types also include all type definitions found in imported schemas. ]
[Definition: In-scope element declarations. Each element declaration is identified either by an expanded QName (for a top-level element declaration) or by an implementation-dependent element identifier (for a local element declaration). If the Schema Aware Feature is supported, in-scope element declarations include all element declarations found in imported schemas. ] An element declaration includes information about the element's substitution group affiliation.
[Definition: Substitution groups are defined in [XML Schema 1.0] and [XML Schema 1.1] Part 1. Informally, the substitution group headed by a given element (called the head element) consists of the set of elements that can be substituted for the head element without affecting the outcome of schema validation.]
[Definition: In-scope attribute declarations. Each attribute declaration is identified either by an expanded QName (for a top-level attribute declaration) or by an implementation-dependent attribute identifier (for a local attribute declaration). If the Schema Aware Feature is supported, in-scope attribute declarations include all attribute declarations found in imported schemas. ]
[Definition: In-scope variables. This is a mapping from expanded QName to type. It defines the set of variables that are available for reference within an expression. The expanded QName is the name of the variable, and the type is the static type of the variable.]
[Definition: Context item static type. This component defines the static type of the context item within the scope of a given expression.]
[Definition: Statically known function signatures. This is a mapping from (expanded QName, arity) to function signatureDM31. ] The entries in this mapping define the set of statically known functions — those functions that are available to be called from a static function call, or referenced from a named function reference. Each such function is uniquely identified by its expanded QName and arity (number of parameters). Given a statically known function's expanded QName and arity, this component supplies the function's signatureDM31, which specifies various static properties of the function, including typesand annotations.
[Definition: Statically known collations. This is an implementation-defined mapping from URI to collation. It defines the names of the collations that are available for use in processing queries and expressions.] [Definition: A collation is a specification of the manner in which strings and URIs are compared and, by extension, ordered. For a more complete definition of collation, see [XQuery and XPath Functions and Operators 3.1].]
[Definition: Statically known collations. This is an implementation-defined mapping from URI to collation. It defines the names of the collations that are available for use in processing queries and expressions.] [Definition: A collation is a specification of the manner in which strings and URIs are compared and, by extension, ordered. For a more complete definition of collation, see [XQuery and XPath Functions and Operators 3.1].]
[Definition: Default collation. This
identifies one of the collations in statically known collations as the
collation to be used by functions and operators for comparing and
ordering values of type xs:string
and
xs:anyURI
(and types derived from them) when no
explicit collation is specified.]
[Definition: Construction mode. The
construction mode governs the behavior of element and document node
constructors. If construction mode is preserve
, the
type of a constructed element node is xs:anyType
, and
all attribute and element nodes copied during node construction
retain their original types. If construction mode is
strip
, the type of a constructed element node is
xs:untyped
; all element nodes copied during node
construction receive the type xs:untyped
, and all
attribute nodes copied during node construction receive the type
xs:untypedAtomic
.]
[Definition: Ordering mode. Ordering
mode, which has the value ordered
or
unordered
, affects the ordering of the result sequence
returned by certain expressions, as discussed in 3.12 Ordered and Unordered
Expressions.]
[Definition:
Default order for empty sequences. This component controls
the processing of empty sequences and NaN
values as
ordering keys in an order by
clause in a FLWOR
expression, as described in 3.11.8
Order By Clause.] Its value may be greatest
or
least
.
[Definition: Boundary-space
policy. This component controls the processing of boundary
whitespace by direct element constructors, as
described in 3.9.1.4 Boundary
Whitespace.] Its value may be preserve
or
strip
.
[Definition: Copy-namespaces
mode. This component controls the namespace bindings that are
assigned when an existing element node is copied by an element
constructor, as described in 3.9.1 Direct Element
Constructors. Its value consists of two parts:
preserve
or no-preserve
, and
inherit
or no-inherit
.]
[Definition: Static Base URI. This is
an absolute URI, used to resolve relative URIs
both during static analysis and during dynamic evaluation. ]
All expressions within a module have the same
static base URI. The Static Base URI can be set using a base URI
declaration. The Static Base URI is available during
dynamic evaluation by use of the fn:static-base-uri
function, and is used implicitly during dynamic evaluation by
functions such as fn:doc
. Relative URI references are
resolved as described in 2.4.6 Resolving a Relative URI
Reference.
[Definition: Statically known
documents. This is a mapping from strings to types. The string
represents the absolute URI of a resource that is potentially
available using the fn:doc
function. The type is the
static type of a
call to fn:doc
with the given URI as its literal
argument. ] If the argument to fn:doc
is a string
literal that is not present in statically known documents,
then the static
type of fn:doc
is
document-node()?
.
[Definition: Statically known
collections. This is a mapping from strings to types. The
string represents the absolute URI of a resource that is
potentially available using the fn:collection
function. The type is the type of the sequence of nodes that would
result from calling the fn:collection
function with
this URI as its argument.] If the argument to
fn:collection
is a string literal that is not present
in statically known collections, then the static type of
fn:collection
is node()*
.
[Definition:
Statically known default collection type. This is the type
of the sequence of nodes that would result from calling the
fn:collection
function with no arguments.] Unless
initialized to some other value by an implementation, the value of
statically known default collection type is
node()*
.
[Definition: Statically
known decimal formats. This is a mapping from QName to decimal
format, with one default format that has no visible name. Each
format is used for serializing decimal numbers using
fn:format-number()
.]
[Definition: The dynamic context of an expression is defined as information that is available at the time the expression is evaluated.] If evaluation of an expression relies on some part of the dynamic context that is absentDM31, a dynamic error is raised [err:XPDY0002].
[Definition: The first three components of the dynamic context (context item, context position, and context size) are called the focus of the expression. ] The focus enables the processor to keep track of which items are being processed by the expression. If any component in the focus is defined, all components of the focus are defined. [Definition: A singleton focus is a focus that refers to a single item; in a singleton focus, context item is set to the item, context position = 1 and context size = 1.]
[Definition: The first three components of the dynamic context (context item, context position, and context size) are called the focus of the expression. ] The focus enables the processor to keep track of which items are being processed by the expression. If any component in the focus is defined, all components of the focus are defined. [Definition: A singleton focus is a focus that refers to a single item; in a singleton focus, context item is set to the item, context position = 1 and context size = 1.]
[Definition: The context item is the
item currently being
processed.] [Definition: When the context item is a node, it
can also be referred to as the context node.] The context
item is returned by an expression consisting of a single dot
(.
). When an expression E1/E2
or
E1[E2]
is evaluated, each item in the sequence
obtained by evaluating E1
becomes the context item in
the inner focus for an evaluation of E2
.
[Definition: The context item is the
item currently being
processed.] [Definition: When the context item is a node, it
can also be referred to as the context node.] The context
item is returned by an expression consisting of a single dot
(.
). When an expression E1/E2
or
E1[E2]
is evaluated, each item in the sequence
obtained by evaluating E1
becomes the context item in
the inner focus for an evaluation of E2
.
[Definition: The initial context item is a context item that an implementation can set before processing a query begins. The query body and the prolog of every module in a query share the same initial context item.]
[Definition: The context position is
the position of the context item within the sequence of items
currently being processed.] It changes whenever the context item
changes. When the focus is defined, the value of the context
position is an integer greater than zero. The context position is
returned by the expression fn:position()
. When an
expression E1/E2
or E1[E2]
is evaluated,
the context position in the inner focus for an evaluation of
E2
is the position of the context item in the sequence
obtained by evaluating E1
. The position of the first
item in a sequence is always 1 (one). The context position is
always less than or equal to the context size.
[Definition: The context size is the
number of items in the sequence of items currently being
processed.] Its value is always an integer greater than zero. The
context size is returned by the expression fn:last()
.
When an expression E1/E2
or E1[E2]
is
evaluated, the context size in the inner focus for an evaluation of
E2
is the number of items in the sequence obtained by
evaluating E1
.
[Definition: Variable values. This is a mapping from expanded QName to value. It contains the same expanded QNames as the in-scope variables in the static context for the expression. The expanded QName is the name of the variable and the value is the dynamic value of the variable, which includes its dynamic type.]
[Definition: Named functions. This is a mapping from (expanded QName, arity) to functionDM31. ] It supplies a function for each signature in statically known function signatures and may supply other functions (see 2.2.5 Consistency Constraints). Named functions can include functions with implementation-dependent implementations; these functions do not have a static context or a dynamic context of their own.
[Definition: Current dateTime. This
information represents an implementation-dependent point
in time during the processing of a
query, and includes an explicit timezone. It can be
retrieved by the fn:current-dateTime
function. If
invoked multiple times during the execution of a query, this function always returns the same
result.]
[Definition: Implicit timezone. This
is the timezone to be used when a date, time, or dateTime value
that does not have a timezone is used in a comparison or arithmetic
operation. The implicit timezone is an implementation-defined value of
type xs:dayTimeDuration
. See [XML Schema 1.0] or [XML
Schema 1.1] for the range of valid values of a timezone.]
[Definition: Default language. This is
the natural language used when creating human-readable output (for
example, by the functions fn:format-date
and
fn:format-integer
) if no other language is requested.
The value is a language code as defined by the type
xs:language
.]
[Definition: Default calendar. This is
the calendar used when formatting dates in human-readable output
(for example, by the functions fn:format-date
and
fn:format-dateTime
) if no other calendar is requested.
The value is a string.]
[Definition: Default place. This is a
geographical location used to identify the place where events
happened (or will happen) when formatting dates and times using
functions such as fn:format-date
and
fn:format-dateTime
, if no other place is specified. It
is used when translating timezone offsets to civil timezone names,
and when using calendars where the translation from ISO dates/times
to a local representation is dependent on geographical location.
Possible representations of this information are an ISO country
code or an Olson timezone name, but implementations are free to use
other representations from which the above information can be
derived.]
[Definition: Available documents.
This is a mapping of strings to document nodes. Each string
represents the absolute URI of a resource. The document node is the
root of a tree that represents that resource using the data model. The document node
is returned by the fn:doc
function when applied to
that URI.] The set of available documents is not limited to the set
of statically known documents, and it may be
empty.
[Definition: Available text
resources. This is a mapping of strings to text resources. Each
string represents the absolute URI of a resource. The resource is
returned by the fn:unparsed-text
function when applied
to that URI.] The set of available text resources is not limited to
the set of statically known documents, and it may be
empty.
[Definition: Available node
collections. This is a mapping of strings to sequences of
nodes. Each string represents the absolute URI of a resource. The
sequence of nodes represents the result of the
fn:collection
function when that URI is supplied as
the argument. ] The set of available node collections is not
limited to the set of statically known collections, and it
may be empty.
[Definition: Default node
collection. This is the sequence of nodes that would result
from calling the fn:collection
function with no
arguments.] The value of default collection may be
initialized by the implementation.
[Definition: Available
resource collections. This is a mapping of strings to sequences
of URIs. The string represents the absolute URI of a resource which
can be interpreted as an aggregation of a number of individual
resources each of which has its own URI. The sequence of URIs
represents the result of the fn:uri-collection
function when that URI is supplied as the argument. ] There is no
implication that the URIs in this sequence can be successfully
dereferenced, or that the resources they refer to have any
particular media type.
[Definition: Default resource
collection. This is the sequence of URIs that would result from
calling the fn:uri-collection
function with no
arguments.] The value of default resource collection may be
initialized by the implementation.
[Definition: Environment variables. This is a mapping from names to values. Both the names and the values are strings. The names are compared using an implementation-defined collation, and are unique under this collation. The set of environment variables is implementation-defined and may be empty.]
[Definition: Each element node and attribute
node in an XDM instance has a type
annotation (described in [XQuery
and XPath Data Model (XDM) 3.1]). The type annotation of a node
is a reference to an XML Schema type. ] The type-name
of a node is the name of the type referenced by its type annotation.
If the XDM
instance was derived from a validated XML document as described
in Section 3.3
Construction from a PSVI DM31, the
type annotations of the element and attribute nodes are derived
from schema validation. XQuery 3.1 does not provide a way to
directly access the type annotation of an element or attribute
node.
[Definition: The static analysis phase depends on the expression itself and on the static context. The static analysis phase does not depend on input data (other than schemas).]
During the static analysis phase, a processor may perform type analysis. The effect of type analysis is to assign a static type to each expression in the operation tree. [Definition: The static type of an expression is the best inference that the processor is able to make statically about the type of the result of the expression.] This specification does not define the rules for type analysis nor the static types that are assigned to particular expressions: the only constraint is that the inferred type must match all possible values that the expression is capable of returning.
[Definition: The dynamic evaluation phase is the phase during which the value of an expression is computed.] It occurs after completion of the static analysis phase.
[Definition: A dynamic type is associated
with each value as it is computed. The dynamic type of a value may
be more specific than the static type of the expression that computed
it (for example, the static type of an expression might be
xs:integer*
, denoting a sequence of zero or more
integers, but at evaluation time its value may have the dynamic
type xs:integer
, denoting exactly one integer.)]
[Definition: Serialization is the process of converting an XDM instance to a sequence of octets (step DM4 in Figure 1.), as described in [XSLT and XQuery Serialization 3.1].]
[Definition:
An output declaration is an option declaration in the
namespace "http://www.w3.org/2010/xslt-xquery-serialization"; it is
used to declare serialization parameters.] Except for
parameter-document
, each option corresponds to a
serialization parameter element defined in
Section B Schema for Serialization Parameters
SER31. The name of each option is the
same as the name of the corresponding serialization parameter
element, and the values permitted for each option are the same as
the values allowed in the serialization parameter element. There is
no output declaration for use-character-maps
, it can
be set only by means of a parameter document. When the application
requests serialization of the output, the processor may use these
parameters to control the way in which the serialization takes
place. Processors may also allow external mechanisms for specifying
serialization parameters, which may or may not override
serialization parameters specified in the query prolog.
[Definition: An error that can be detected during the static analysis phase, and is not a type error, is a static error.] A syntax error is an example of a static error.
[Definition: A dynamic error is an error that must be detected during the dynamic evaluation phase and may be detected during the static analysis phase. Numeric overflow is an example of a dynamic error . ]
[Definition: A type error may be raised during the static analysis phase or the dynamic evaluation phase. During the static analysis phase, a type error occurs when the static type of an expression does not match the expected type of the context in which the expression occurs. During the dynamic evaluation phase, a type error occurs when the dynamic type of a value does not match the expected type of the context in which the value occurs.]
[Definition: In addition to static errors, dynamic errors, and type errors, an XQuery 3.1 implementation may raise warnings, either during the static analysis phase or the dynamic evaluation phase. The circumstances in which warnings are raised, and the ways in which warnings are handled, are implementation-defined.]
[Definition: In addition to its identifying QName, a dynamic error may also carry a descriptive string and one or more additional values called error values.] An implementation may provide a mechanism whereby an application-defined error handler can process error values and produce diagnostic messages. XQuery 3.1 provides standard error handling via Section 3.16 Try/Catch Expressions XQ31 .
An ordering called document order is defined among all the nodes accessible during processing of a given query, which may consist of one or more trees (documents or fragments). Document order is defined in [XQuery and XPath Data Model (XDM) 3.1], and its definition is repeated here for convenience. Document order is a total ordering, although the relative order of some nodes is implementation-dependent. [Definition: Informally, document order is the order in which nodes appear in the XML serialization of a document.] [Definition: Document order is stable, which means that the relative order of two nodes will not change during the processing of a given query, even if this order is implementation-dependent.] [Definition: The node ordering that is the reverse of document order is called reverse document order.]
An ordering called document order is defined among all the nodes accessible during processing of a given query, which may consist of one or more trees (documents or fragments). Document order is defined in [XQuery and XPath Data Model (XDM) 3.1], and its definition is repeated here for convenience. Document order is a total ordering, although the relative order of some nodes is implementation-dependent. [Definition: Informally, document order is the order in which nodes appear in the XML serialization of a document.] [Definition: Document order is stable, which means that the relative order of two nodes will not change during the processing of a given query, even if this order is implementation-dependent.] [Definition: The node ordering that is the reverse of document order is called reverse document order.]
The semantics of some XQuery 3.1 operators depend on a process
called atomization. Atomization is applied to a
value when the value is used in a context in which a sequence of
atomic values is required. The result of atomization is either a
sequence of atomic values or a type error [err:FOTY0012]. [Definition: Atomization of a sequence is
defined as the result of invoking the fn:data
function
on the sequence, as defined in [XQuery and XPath Functions and Operators
3.1].]
Under certain circumstances (listed below), it is necessary to
find the effective boolean value of a value. [Definition: The
effective boolean value of a value is defined as the result
of applying the fn:boolean
function to the value, as
defined in [XQuery and XPath
Functions and Operators 3.1].]
[Definition: To resolve a relative URI
$rel
against a base URI $base
is to
expand it to an absolute URI, as if by calling the function
fn:resolve-uri($rel, $base)
.] During static analysis,
the base URI is the Static Base URI. During dynamic evaluation, the
base URI used to resolve a relative URI reference depends on the
semantics of the expression.
[Definition: A sequence type is a type that can be expressed using the SequenceType syntax. Sequence types are used whenever it is necessary to refer to a type in an XQuery 3.1 expression. The term sequence type suggests that this syntax is used to describe the type of an XQuery 3.1 value, which is always a sequence.]
[Definition: A schema type is a type that
is (or could be) defined using the facilities of [XML Schema 1.0] or [XML
Schema 1.1] (including the built-in types of [XML Schema 1.0] or [XML
Schema 1.1]).] A schema type can be used as a type annotation
on an element or attribute node (unless it is a non-instantiable
type such as xs:NOTATION
or
xs:anyAtomicType
, in which case its derived types can
be so used). Every schema type is either a complex type or a
simple type; simple types are further subdivided into
list types, union types, and atomic types (see
[XML Schema 1.0] or [XML Schema 1.1] for definitions and
explanations of these terms.)
[Definition: A generalized atomic type is a type which is either (a) an atomic type or (b) a pure union type ].
[Definition: A pure union type is an
XML Schema union type that satisfies the following constraints: (1)
{variety}
is union
, (2) the
{facets}
property is empty, (3) no type in the
transitive membership of the union type has {variety}
list
, and (4) no type in the transitive membership of
the union type is a type with {variety}
union
having a non-empty {facets}
property].
[Definition: xs:untyped
is used as the
type
annotation of an element node that has not been validated, or
has been validated in skip
mode.] No predefined schema
types are derived from xs:untyped
.
[Definition: xs:untypedAtomic
is
an atomic type that is used to denote untyped atomic data, such as
text that has not been assigned a more specific type.] An attribute
that has been validated in skip
mode is represented in
the data model by an
attribute node with the type annotation
xs:untypedAtomic
. No predefined schema types are
derived from xs:untypedAtomic
.
[Definition:
xs:dayTimeDuration
is derived by restriction from
xs:duration
. The lexical representation of
xs:dayTimeDuration
is restricted to contain only day,
hour, minute, and second components.]
[Definition:
xs:yearMonthDuration
is derived by restriction from
xs:duration
. The lexical representation of
xs:yearMonthDuration
is restricted to contain only
year and month components.]
[Definition: xs:anyAtomicType
is
an atomic type that includes all atomic values (and no values that
are not atomic). Its base type is xs:anySimpleType
from which all simple types, including atomic, list, and union
types, are derived. All primitive atomic types, such as
xs:decimal
and xs:string
, have
xs:anyAtomicType
as their base type.]
[Definition: xs:error
is a simple type
with no value space, defined in [XML Schema
1.1]. In implementations that support XML Schema 1.1, it can be
used in the 2.5.4 SequenceType
Syntax to raise errors.]
[Definition: The
namespace-sensitive types are xs:QName
,
xs:NOTATION
, types derived by restriction from
xs:QName
or xs:NOTATION
, list types that
have a namespace-sensitive item type, and union types with a
namespace-sensitive type in their transitive membership.]
Every node has a typed value and a string value,
except for nodes whose value is absentDM31.
[Definition: The typed value of a node is a
sequence of atomic values and can be extracted by applying the
fn:data
function to the node.] [Definition: The string value of a node is
a string and can be extracted by applying the
fn:string
function to the node.] Definitions of
fn:data
and fn:string
can be found in
[XQuery and XPath Functions and
Operators 3.1].
Every node has a typed value and a string value,
except for nodes whose value is absentDM31.
[Definition: The typed value of a node is a
sequence of atomic values and can be extracted by applying the
fn:data
function to the node.] [Definition: The string value of a node is
a string and can be extracted by applying the
fn:string
function to the node.] Definitions of
fn:data
and fn:string
can be found in
[XQuery and XPath Functions and
Operators 3.1].
[Definition: SequenceType
matching compares the dynamic type of a value with an expected
sequence
type. ] For example, an instance of
expression
returns true
if the dynamic type of a given value matches a
given sequence
type, or false
if it does not.
[Definition: The use of a value
whose dynamic
type is derived from an expected type is known as subtype
substitution.] Subtype substitution does not change the actual
type of a value. For example, if an xs:integer
value
is used where an xs:decimal
value is expected, the
value retains its type as xs:integer
.
[Definition: A function assertion is a predicate that restricts the set of functions matched by a FunctionTest. It uses the same syntax as 4.15 Annotations.] XQuery 3.1 does not currently define any function assertions, but future versions may. Other specifications in the XQuery family may also use function assertions in the future.
Given two sequence types, it is possible to determine
if one is a subtype of the other. [Definition: A sequence type
A
is a subtype of a sequence type
B
if the judgement subtype(A, B)
is
true.] When the judgement subtype(A, B)
is true, it is
always the case that for any value V
, (V
instance of A)
implies (V instance of B)
.
[Definition: Primary expressions are the basic primitives of the language. They include literals, variable references, context item expressions, constructors, and function calls. A primary expression may also be created by enclosing any expression in parentheses, which is sometimes helpful in controlling the precedence of operators.] Node Constructors are described in 3.9 Constructors. Map and Array Constructors are described in 3.10 Maps and Arrays.
[Definition: A literal is a direct syntactic representation of an atomic value.] XQuery 3.1 supports two kinds of literals: numeric literals and string literals.
A string literal may contain a predefined entity reference. [Definition: A predefined entity reference is a short sequence of characters, beginning with an ampersand, that represents a single character that might otherwise have syntactic significance.] Each predefined entity reference is replaced by the character it represents when the string literal is processed. The predefined entity references recognized by XQuery are as follows:
A string literal may also contain a character
reference. [Definition: A character reference
is an XML-style reference to a [Unicode]
character, identified by its decimal or hexadecimal codepoint.] For
example, the Euro symbol (€) can be represented by the character
reference €
. Character references are
normatively defined in Section 4.1 of the XML specification (it is
implementation-defined whether the
rules in [XML 1.0] or [XML
1.1] apply.) A static error [err:XQST0090] is raised if a character reference
does not identify a valid character in the version of XML that is
in use.
[Definition: A variable
reference is an EQName preceded by a $-sign.] An unprefixed
variable reference is in no namespace. Two variable references are
equivalent if their expanded QNames are equal (as defined by
the eq
operator). The scope of a variable binding is
defined separately for each kind of expression that can bind
variables.
[Definition: The built-in functions supported by XQuery 3.1 are defined in [XQuery and XPath Functions and Operators 3.1].] Additional functions may be declared in a Prolog, imported from a library module, or provided by the external environment as part of the static context.
[Definition: A static function call consists of an EQName followed by a parenthesized list of zero or more arguments.] [Definition: An argument to a function call is either an argument expression or an ArgumentPlaceholder ("?").] If the EQName in a static function call is a lexical QName that has no namespace prefix, it is considered to be in the default function namespace.
[Definition: A static function call consists of an EQName followed by a parenthesized list of zero or more arguments.] [Definition: An argument to a function call is either an argument expression or an ArgumentPlaceholder ("?").] If the EQName in a static function call is a lexical QName that has no namespace prefix, it is considered to be in the default function namespace.
[Definition: A static or dynamic function call is a partial function application if one or more arguments is an ArgumentPlaceholder. ]
[Definition: The number of Argument
s
in an ArgumentList
is its arity. ]
[Definition: Argument expressions are evaluated with respect to DC, producing argument values.] The order of argument evaluation is implementation-dependent and a function need not evaluate an argument if the function can evaluate its body without evaluating that argument.
[Definition: In a partial function application,
a fixed position is an argument/parameter position for which
the ArgumentList
has an argument expression (as
opposed to an ArgumentPlaceholder
). ] (Note that a
partial function application need not have any fixed
positions.)
[Definition: The function conversion rules are used to convert an argument value or a return value to its expected type; that is, to the declared type of the function parameter or return. ] The expected type is expressed as a sequence type. The function conversion rules are applied to a given value as follows:
Function coercion is a transformation applied to functionsDM31 during application of the function conversion rules. [Definition: Function coercion wraps a functionDM31 in a new function with signature the same as the expected type. This effectively delays the checking of the argument and return types until the function is invoked.]
[Definition: A named function reference denotes a named function.] [Definition: A named function is a function defined in the static context for the query. To uniquely identify a particular named function, both its name as an expanded QName and its arity are required.]
[Definition: A named function reference denotes a named function.] [Definition: A named function is a function defined in the static context for the query. To uniquely identify a particular named function, both its name as an expanded QName and its arity are required.]
[Definition: An inline function expression creates an anonymous functionDM31 defined directly in the inline function expression itself.] An inline function expression specifies the names and SequenceTypes of the parameters to the function, the SequenceType of the result, and the body of the function.
[Definition: An expression followed by a
predicate (that is, E1[E2]
) is referred to as a
filter expression: its effect is to return those items from
the value of E1
that satisfy the predicate in E2.]
Filter expressions are described in 3.2.1 Filter Expressions
If the value of the predicate expression is a singleton atomic value of a
numeric type or derived
from a numeric type, the
predicate truth value is true
if the value of the
predicate expression is equal (by the eq
operator) to
the context position, and is false
otherwise.
[Definition: A predicate whose predicate
expression returns a numeric type is called a numeric
predicate.]
[Definition: A dynamic function call consists of a base expression that returns the function and a parenthesized list of zero or more arguments (argument expressions or ArgumentPlaceholders).]
[Definition: An arrow operator is a
postfix operator that applies a function to an item, using the item
as the first argument to the function.] If $s
is
a sequence and f()
is a function, then
$s=>f()
is equivalent to f($s)
, and
$s=>f($j)
is equivalent to f($s,
$j)
.
[Definition: A path expression can be
used to locate nodes within trees. A path expression consists of a
series of one or more steps,
separated by "/
" or "//
", and optionally
beginning with "/
" or "//
".] An initial
"/
" or "//
" is an abbreviation for one or
more initial steps that are implicitly added to the beginning of
the path expression, as described below.
[Definition: A step is a part of a path expression that generates a sequence of items and then filters the sequence by zero or more predicates. The value of the step consists of those items that satisfy the predicates, working from left to right. A step may be either an axis step or a postfix expression.] Postfix expressions are described in 3.2 Postfix Expressions.
[Definition: An axis step returns a sequence
of nodes that are reachable from the context node via a specified
axis. Such a step has two parts: an axis, which defines the
"direction of movement" for the step, and a node test, which selects nodes based on
their kind, name, and/or type annotation.] If the context item is
a node, an axis step returns a sequence of zero or more nodes;
otherwise, a type
error is raised [err:XPTY0020]. If ordering mode is
ordered
, the resulting node sequence is returned in
document
order; otherwise it is returned in implementation-dependent
order. An axis step may be either a forward step or a
reverse step, followed by zero or more predicates.
[Definition: Every axis has a principal node kind. If an axis can contain elements, then the principal node kind is element; otherwise, it is the kind of nodes that the axis can contain.] Thus:
[Definition: A node test is a condition on the name, kind (element, attribute, text, document, comment, or processing instruction), and/or type annotation of a node. A node test determines which nodes contained by an axis are selected by a step.]
[Definition: A node test that consists only of an
EQName or a Wildcard is called a name test.] A name test is
true if and only if the kind of the node is the principal node
kind for the step axis and the expanded QName of the node is equal (as
defined by the eq
operator) to the expanded QName
specified by the name test. For example, child::para
selects the para
element children of the context node;
if the context node has no para
children, it selects
an empty set of nodes. attribute::abc:href
selects the
attribute of the context node with the QName abc:href
;
if the context node has no such attribute, it selects an empty set
of nodes.
[Definition: An alternative form of a node test called a kind test can select nodes based on their kind, name, and type annotation.] The syntax and semantics of a kind test are described in 2.5.4 SequenceType Syntax and 2.5.5 SequenceType Matching. When a kind test is used in a node test, only those nodes on the designated axis that match the kind test are selected. Shown below are several examples of kind tests that might be used in path expressions:
[Definition: One way to construct a sequence is by using the comma operator, which evaluates each of its operands and concatenates the resulting sequences, in order, into a single result sequence.] Empty parentheses can be used to denote an empty sequence.
An element constructor creates an element node. [Definition: A direct element
constructor is a form of element constructor in which the name
of the constructed element is a constant.] Direct element
constructors are based on standard XML notation. For example, the
following expression is a direct element constructor that creates a
book
element containing an attribute and some nested
elements:
[Definition: A
namespace declaration attribute is used inside a direct
element constructor. Its purpose is to bind a namespace prefix or
to set the default element/type namespace for the
constructed element node, including its attributes.] Syntactically,
a namespace declaration attribute has the form of an attribute with
namespace prefix xmlns
, or with name
xmlns
and no namespace prefix. All the namespace
declaration attributes of a given element must have distinct names
[err:XQST0071].
Each namespace declaration attribute is processed as follows:
[Definition: Boundary
whitespace is a sequence of consecutive whitespace characters
within the content of a direct element constructor, that is
delimited at each end either by the start or end of the content, or
by a DirectConstructor, or by an
EnclosedExpr. For this
purpose, characters generated by character references such as
 
or by CDataSections are not considered
to be whitespace characters.]
For those kinds of nodes that have names (element, attribute, and processing instruction nodes), the keyword that specifies the node kind is followed by the name of the node to be created. This name may be specified either as an EQName or as an expression enclosed in braces. [Definition: When an expression is used to specify the name of a constructed node, that expression is called the name expression of the constructor.]
[Definition: The final part of a computed constructor is an expression enclosed in braces, called the content expression of the constructor, that generates the content of the node.]
[Definition: A computed element constructor creates an element node, allowing both the name and the content of the node to be computed.]
[Definition: A map is a function that associates a set of keys with values, resulting in a collection of key / value pairs.] [Definition: Each key / value pair in a map is called an entry.] [Definition: The value associated with a given key is called the associated value of the key.]
[Definition: A map is a function that associates a set of keys with values, resulting in a collection of key / value pairs.] [Definition: Each key / value pair in a map is called an entry.] [Definition: The value associated with a given key is called the associated value of the key.]
[Definition: A map is a function that associates a set of keys with values, resulting in a collection of key / value pairs.] [Definition: Each key / value pair in a map is called an entry.] [Definition: The value associated with a given key is called the associated value of the key.]
[Definition: Two atomic values K1 and K2 have the same key value if the relation deep-equal(K1, K2, $UCC) holds, where $UCC is the Unicode codepoint collation.] If two or more entries have the same key value then a dynamic error is raised [err:XQDY0137].
[Definition: An array is a function that associates a set of positions, represented as positive integer keys, with values.] The first position in an array is associated with the integer 1. [Definition: The values of an array are called its members.] In the type hierarchy, array has a distinct type, which is derived from function. Atomization converts arrays to sequences (see Atomization).
[Definition: An array is a function that associates a set of positions, represented as positive integer keys, with values.] The first position in an array is associated with the integer 1. [Definition: The values of an array are called its members.] In the type hierarchy, array has a distinct type, which is derived from function. Atomization converts arrays to sequences (see Atomization).
[Definition: A variable binding may be
accompanied by a type declaration, which consists of the
keyword as
followed by the static type of the
variable, declared using the syntax in 2.5.4 SequenceType Syntax.] At
run time, if the value bound to the variable does not match the
declared type according to the rules for SequenceType matching, a type error is raised
[err:XPTY0004]. For
example, the following let
clause raises a type error because the
variable $salary
has a type declaration that is not
satisfied by the value that is bound to it:
[Definition: In a for
clause or
window
clause, when an expression is preceded by the
keyword in
, the value of that expression is called a
binding sequence.] The for
and
window
clauses iterate over their binding sequences,
producing multiple bindings for one or more variables. Details on
how binding sequences are used in for
and
window
clauses are described in the following
sections.
[Definition: A positional
variable is a variable that is preceded by the keyword
at
.] A positional variable may be associated with a
variable that is bound in a for
clause. In this case,
as the main variable iterates over the items in its binding
sequence, the positional variable iterates over the integers
that represent the ordinal numbers of these items in the binding
sequence, starting with one. Each tuple in the output tuple
stream contains bindings for both the main variable and the
positional variable. If the binding sequence is empty and
allowing empty
is specified, the positional variable
in the output tuple is bound to the integer zero. Positional
variables always have the implied type xs:integer
. The
expanded
QName of a positional variable must be distinct from the
expanded
QName of the main variable with which it is associated
[err:XQST0089].
Like a for
clause, a window
clause
iterates over its binding sequence and generates a
sequence of tuples. In the case of a window
clause,
each tuple represents a window. [Definition: A window is a sequence of
consecutive items drawn from the binding sequence.] Each window is
represented by at least one and at most nine bound variables. The
variables have user-specified names, but their roles are as
follows:
A group by
clause contains one or more grouping specifications, as shown
in the grammar. [Definition:
Each grouping specification specifies one grouping variable, which
refers to variable bindings in the pre-grouping tuples. The values
of the grouping variables are used to assign pre-grouping tuples to
groups.] Each grouping specification may optionally provide an
expression to which its grouping variable is bound. If no
expression is provided, the grouping variable name must be equal
(by the eq
operator on expanded QNames) to the name of a variable
in the input tuple stream, and it refers to that variable;
otherwise a static
error is raised [err:XQST0094]. For each grouping specification
that contains a binding expression, a let
binding is
created in the pre-grouping tuples, and the grouping variable
refers to that let
binding. For example, the
clause:
[Definition: The atomized value of a grouping variable is called a grouping key.] For each pre-grouping tuple, the grouping keys are created by atomizing the values of the grouping variables (in the post-grouping tuples, each grouping variable is set to the value of the corresponding grouping key, as discussed below). If the value of any grouping variable consists of more than one item, a type error is raised [err:XPTY0004]. If a type declaration is present and the resulting atomized value is not an instance of the specified type, a type error is raised [err:XPTY0004].
The input tuple stream is partitioned into groups of tuples
whose grouping keys are equivalent. [Definition: Two tuples
T1 and T2 have equivalent grouping
keys if and only if, for each grouping variable GV,
the atomized value of GV in T1 is deep-equal
to the atomized value of GV in T2, as defined
by applying the function fn:deep-equal
using the
appropriate collation.] If these values are of different numeric
types, and differ from each other by small amounts, then the
deep-equal relationship is not transitive, because of rounding
effects occurring during type promotion. When comparing three
values A
, B
, and C
such that
A eq B
, B eq C
, but A ne C
,
then the number of items in the result of the function (as well as
the choice of which items are returned) is
subject only to the constraints that (a) no two items in the result
sequence compare equal to each other, and (b) every input item that
does not appear in the result sequence compares equal to some item
that does appear in the result sequence. See Section
14.2.1 fn:distinct-values FO31 for
further discussion of this issue in a different context.
Each case
clause specifies one or
more SequenceTypes
followed by a return
expression. [Definition: The effective case in a
typeswitch
expression is the first case
clause in which the value of the operand expression matches a
SequenceType in the
SequenceTypeUnion of the
case
clause, using the rules of SequenceType matching. ] The value
of the typeswitch
expression is the value of the
return
expression in the effective case. If the value
of the operand expression does not match any SequenceType named in a
case
clause, the value of the typeswitch
expression is the value of the return
expression in
the default
clause.
[Definition: The constructor
function for a given type is used to convert instances of other
atomic types into the given type. The semantics of the constructor
function call T($arg)
are defined to be equivalent to
the expression (($arg) cast as T?)
.]
[Definition: An extension expression is an expression whose semantics are implementation-defined.] Typically a particular extension will be recognized by some implementations and not by others. The syntax is designed so that extension expressions can be successfully parsed by all implementations, and so that fallback behavior can be defined for implementations that do not recognize a particular extension.
An extension expression consists of one or more pragmas,
followed by an expression enclosed in curly braces. [Definition: A
pragma is denoted by the delimiters (#
and
#)
, and consists of an identifying EQName followed by
implementation-defined content.]
The content of a pragma may consist of any string of characters
that does not contain the ending delimiter #)
. If the
EQName of a pragma is a lexical QName, it must resolve to a namespace URI
and local name, using the statically known namespaces
[err:XPST0081].
A query can be assembled from one or more fragments called modules. [Definition: A module is a fragment of XQuery code that conforms to the Module grammar and can independently undergo the static analysis phase described in 2.2.3 Expression Processing. Each module is either a main module or a library module.]
[Definition: A main module consists of a Prolog followed by a Query Body.] A query has exactly one main module. In a main module, the Query Body is evaluated with respect to the static and dynamic contexts of the main module in which it is found, and its value is the result of the query.
[Definition: A module that does not contain a Query Body is called a library module. A library module consists of a module declaration followed by a Prolog.] A library module cannot be evaluated directly; instead, it provides function and variable declarations that can be imported into other modules.
[Definition: A Prolog is a series of declarations and imports that define the processing environment for the module that contains the Prolog.] Each declaration or import is followed by a semicolon. A Prolog is organized into two parts.
The first part of the Prolog consists of setters, imports, namespace declarations, and default namespace declarations. [Definition: Setters are declarations that set the value of some property that affects query processing, such as construction mode, ordering mode, or default collation.] Namespace declarations and default namespace declarations affect the interpretation of lexical QNames within the query. Imports are used to import definitions from schemas and modules. [Definition: The target namespace of a module is the namespace of the objects (such as elements or functions) that it defines. ]
The first part of the Prolog consists of setters, imports, namespace declarations, and default namespace declarations. [Definition: Setters are declarations that set the value of some property that affects query processing, such as construction mode, ordering mode, or default collation.] Namespace declarations and default namespace declarations affect the interpretation of lexical QNames within the query. Imports are used to import definitions from schemas and modules. [Definition: The target namespace of a module is the namespace of the objects (such as elements or functions) that it defines. ]
[Definition: The Query Body, if present, consists of an expression that defines the result of the query.] Evaluation of expressions is described in 3 Expressions. A module can be evaluated only if it has a Query Body.
[Definition: A version declaration can identify the applicable XQuery syntax and semantics for a module, as well as its encoding.] The version number "1.0" indicates the intent that the module be processed by an XQuery 1.0 processor, the version number "3.0" indicates the intent that the module be processed by an XQuery 3.0 processor XQuery 1.0 processor, the version number "3.1" indicates the intent that the module be processed by an XQuery 3.1 processor. If the version declaration is not present or the version is not included in the declaration, an XQuery 3.1 processor assumes a version of "3.1". If an XQuery 3.1 processor processes a module labeled with a version other than "3.1", it must do one of the following:
[Definition: If present, a version
declaration may optionally include an encoding declaration.
The value of the string literal following the keyword
encoding
is an encoding name, and must conform to the
definition of EncName
specified in [XML
1.0] [err:XQST0087]. The purpose of an encoding
declaration is to allow the writer of a query to provide a string
that indicates how the query is encoded, such as
"UTF-8
", "UTF-16
", or
"US-ASCII
".] Since the encoding of a query may change
as the query moves from one environment to another, there can be no
guarantee that the encoding declaration is correct.
[Definition: A module
declaration serves to identify a module as a library module. A module declaration
begins with the keyword module
and contains a
namespace prefix and a URILiteral.] The URILiteral must be
of nonzero length [err:XQST0088]. The URILiteral identifies the
target
namespace of the library module, which is the namespace for all
variables and functions exported by the library module. The name of
every variable and function declared in a library module must have
a namespace URI that is the same as the target namespace of the
module; otherwise a static error is raised [err:XQST0048]. The
(prefix,URI) pair is added to the set of statically known namespaces.
[Definition: A
boundary-space declaration sets the boundary-space policy in the
static
context, overriding any implementation-defined default.
Boundary-space policy controls whether boundary
whitespace is preserved by element constructors during
processing of the query.] If boundary-space policy is
preserve
, boundary whitespace is preserved. If
boundary-space policy is strip
, boundary whitespace is
stripped (deleted). A further discussion of whitespace in
constructed elements can be found in 3.9.1.4 Boundary Whitespace.
[Definition: A default
collation declaration sets the value of the default collation
in the static
context, overriding any implementation-defined default.] The
default collation is the collation that is used by functions and
operators that require a collation if no other collation is
specified. For example, the gt
operator on strings is
defined by a call to the fn:compare
function, which
takes an optional collation parameter. Since the gt
operator does not specify a collation, the fn:compare
function implements gt
by using the default
collation.
[Definition: A base URI
declaration specifies the Static Base URI property. The Static Base URI
property is used when resolving relative URI references.] For
example, the Static Base URI property is used when
resolving relative references for module import and for the
fn:doc
function.
[Definition: A construction
declaration sets the construction mode in the static context,
overriding any implementation-defined default.] The construction
mode governs the behavior of element and document node
constructors. If construction mode is preserve
, the
type of a constructed element node is xs:anyType
, and
all attribute and element nodes copied during node construction
retain their original types. If construction mode is
strip
, the type of a constructed element node is
xs:untyped
; all element nodes copied during node
construction receive the type xs:untyped
, and all
attribute nodes copied during node construction receive the type
xs:untypedAtomic
.
[Definition: An ordering
mode declaration sets the ordering mode in the static context,
overriding any implementation-defined default.] This ordering mode
applies to all expressions in a module (including both the Prolog and the Query Body, if any), unless overridden by an
ordered
or unordered
expression.
[Definition: An empty order
declaration sets the default order for empty sequences in
the static
context, overriding any implementation-defined default. This
declaration controls the processing of empty sequences and
NaN
values as ordering keys in an order
by
clause in a FLWOR expression.] An individual order
by
clause may override the default order for empty sequences
by specifying empty greatest
or empty
least
.
[Definition: A copy-namespaces declaration sets the value of copy-namespaces mode in the static context, overriding any implementation-defined default. Copy-namespaces mode controls the namespace bindings that are assigned when an existing element node is copied by an element constructor or document constructor.] Handling of namespace bindings by element constructors is described in 3.9.1 Direct Element Constructors.
[Definition: A decimal
format declaration adds a decimal format to the statically known decimal formats,
which define the properties used to format numbers using the
fn:format-number()
function], as described in [XQuery and XPath Functions and Operators
3.1]. The mapping between these properties and the equivalent
fn:format-number()
properties is discussed in
statically known decimal formats,
which also specifies the defaults for each value. If a format
declares no properties, default values are used for all
properties.
[Definition: A schema import imports the element declarations, attribute declarations, and type definitions from a schema into the in-scope schema definitions. For each named user-defined simple type in the schema, schema import also adds a corresponding constructor function. ] The schema to be imported is identified by its target namespace. The schema import may bind a namespace prefix to the target namespace of the imported schema, adding the (prefix, URI) pair to the statically known namespaces, or it may declare that target namespace to be the default element/type namespace. The schema import may also provide optional hints for locating the schema.
[Definition: A module import imports the public variable declarations and public function declarations from one or more library modules into the statically known function signatures and in-scope variables of the importing module.] Each module import names a target namespace and imports an implementation-defined set of modules that share this target namespace. The module import may bind a namespace prefix to the target namespace, adding the (prefix, URI) pair to the statically known namespaces, and it may provide optional hints for locating the modules to be imported.
[Definition: A namespace declaration declares a namespace prefix and associates it with a namespace URI, adding the (prefix, URI) pair to the set of statically known namespaces.] The namespace declaration is in scope throughout the query in which it is declared, unless it is overridden by a namespace declaration attribute in a direct element constructor.
All variable names declared in a library module must (when
expanded) be in the target namespace of the library module
[err:XQST0048]. A
variable declaration may use annotations to specify that the
variable is %private
or %public
(which is
the default). [Definition: A
private variable is a variable with a %private
annotation. A private variable is hidden from module import, which
can not import it into the in-scope variables of another module.]
[Definition: A public variable is a
variable without a %private
annotation. A public
variable is accessible to module import, which can import it into the
in-scope variables of another module.
Using %public
and %private
annotations in
a main module is not an error, but it does not affect module
imports, since a main module cannot be imported. It is a static error [err:XQST0116] if a variable
declaration contains both a %private
and a
%public
annotation, more than one
%private
annotation, or more than one
%public
annotation.]
All variable names declared in a library module must (when
expanded) be in the target namespace of the library module
[err:XQST0048]. A
variable declaration may use annotations to specify that the
variable is %private
or %public
(which is
the default). [Definition: A
private variable is a variable with a %private
annotation. A private variable is hidden from module import, which
can not import it into the in-scope variables of another module.]
[Definition: A public variable is a
variable without a %private
annotation. A public
variable is accessible to module import, which can import it into the
in-scope variables of another module.
Using %public
and %private
annotations in
a main module is not an error, but it does not affect module
imports, since a main module cannot be imported. It is a static error [err:XQST0116] if a variable
declaration contains both a %private
and a
%public
annotation, more than one
%private
annotation, or more than one
%public
annotation.]
[Definition: If a variable declaration
includes an expression (VarValue
or
VarDefaultValue
), the expression is called an
initializing expression. The static context for an
initializing expression includes all functions, variables, and
namespaces that are declared or imported anywhere in the Prolog,
other than the variable being declared.]
In a module's dynamic context, a variable value (or the context item) may depend on another variable value (or the context item). [Definition: A variable value (or the context item) depends on another variable value (or the context item) if, during the evaluation of the initializing expression of the former, the latter is accessed through the module context.]
[Definition: User defined functions are functions that contain a function body, which provides the implementation of the function as an XQuery expression.] The static context for a function body includes all functions, variables, and namespaces that are declared or imported anywhere in the Prolog, including the function being declared. Its in-scope variables component also includes the parameters of the function being declared. However, its context item static type component is absentDM31.
[Definition: External functions are
functions that are implemented outside the query environment.] For
example, an XQuery implementation might provide a set of external
functions in addition to the core function library described in
[XQuery and XPath Functions and
Operators 3.1]. External functions are identified by the
keyword external
. The purpose of a function
declaration for an external function is to declare the datatypes of
the function parameters and result, for use in type checking of the
query that contains or imports the function declaration.
A function declaration may use the %private
or
%public
annotations to specify that a function is
public or private; if neither of these annotations is used, the
function is public. [Definition: A
private function is a function with a %private
annotation. A private function is hidden from module import, which
can not import it into the statically known function
signatures of another module. ] [Definition: A
public function is a function without a
%private
annotation. A public function is accessible
to module
import, which can import it into the statically known function
signatures of another module. ] Using %public
and
%private
annotations in a main module is not an error,
but it does not affect module imports, since a main module cannot
be imported. It is a static error [err:XQST0106] if a function declaration contains
both a %private
and a %public
annotation,
more than one %private
annotation, or more than one
%public
annotation.
A function declaration may use the %private
or
%public
annotations to specify that a function is
public or private; if neither of these annotations is used, the
function is public. [Definition: A
private function is a function with a %private
annotation. A private function is hidden from module import, which
can not import it into the statically known function
signatures of another module. ] [Definition: A
public function is a function without a
%private
annotation. A public function is accessible
to module
import, which can import it into the statically known function
signatures of another module. ] Using %public
and
%private
annotations in a main module is not an error,
but it does not affect module imports, since a main module cannot
be imported. It is a static error [err:XQST0106] if a function declaration contains
both a %private
and a %public
annotation,
more than one %private
annotation, or more than one
%public
annotation.
[Definition: An option declaration declares an option that affects the behavior of a particular implementation. Each option consists of an identifying EQName and a StringLiteral.]
[Definition: The Schema Aware
Feature permits the query Prolog to contain a schema import, and
permits a query to contain a validate
expression (see
3.19 Validate Expressions). ]
[Definition: The Typed Data
Feature permits an XDM instance to contain element node types
other than xs:untyped
and attributes node types other
than xs:untypedAtomic
.]
[Definition: The Static Typing Feature requires implementations to report all type errors during the static analysis phase.]
[Definition: The Module Feature allows a query Prolog to contain a Module Import and allows library modules to be created.]
[Definition: The Serialization Feature provides means for serializing the result of a query as specified in 2.2.4 Serialization.] A conforming XQuery implementation that provides the Serialization Feature MUST conform to 2.2.4 Serialization. An implementation MAY provide other forms of serialization, which do not conform to the Serialization Feature, and are beyond the scope of this specification.
[Definition: The Higher Order Function Feature allows an expression to evaluate to a function, and allows dynamic function calls.]
[Definition: The fn:put() Feature
allows the fn:put()
function, defined in [XQuery Update Facility 3.0] , to be used
in a query.] This feature is defined as an update because
fn:put()
has side effects. It is provided as a
separate feature because some implementations may want to be able
to output files even if they do not conform to the XQuery Update
Facility specification.
[Definition: Under certain circumstances, an
atomic value can be promoted from one type to another. Type
promotion is used in evaluating function calls (see 3.1.5.1 Evaluating Static and Dynamic
Function Calls), order by
clauses (see 3.11.8 Order By
Clause), and operators that accept numeric or string
operands (see B.2 Operator Mapping).]
The following type promotions are permitted:
The operator mapping tables in this section list the combinations of types for which the various operators of XQuery 3.1 are defined. [Definition: For each operator and valid combination of operand types, the operator mapping tables specify a result type and an operator function that implements the semantics of the operator for the given types.] The definitions of the operator functions are given in [XQuery and XPath Functions and Operators 3.1]. The result of an operator may be the raising of an error by its operator function, as defined in [XQuery and XPath Functions and Operators 3.1]. In some cases, the operator function does not implement the full semantics of a given operator. For the definition of each operator (including its behavior for empty sequences or sequences of length greater than one), see the descriptive material in the main part of this document.
[Definition: When referring to a type, the term
numeric denotes the types xs:integer
,
xs:decimal
, xs:float
, and
xs:double
which are all member types of the
built-in union type xs:numeric
.] An operator
whose operands and result are designated as numeric might be thought of as representing
four operators, one for each of the numeric types. For example, the
numeric +
operator might be thought of as representing
the following four operators:
[Definition: In the operator mapping tables, the
term Gregorian refers to the types
xs:gYearMonth
, xs:gYear
,
xs:gMonthDay
, xs:gDay
, and
xs:gMonth
.] For binary operators that accept two
Gregorian-type operands, both operands must have the same type (for
example, if one operand is of type xs:gDay
, the other
operand must be of type xs:gDay
.)
Errors or comments to:patrick@durusau.net
XQuery 3.1 http://www.w3.org/TR/2014/CR-xquery-31-20141218/ Definitions by Patrick Durusau is licensed under a Creative Commons Attribution 4.0 International License.