diff --git a/specifications/xquery-40/src/back-matter.xml b/specifications/xquery-40/src/back-matter.xml index 110dec882..c7bfddbe8 100644 --- a/specifications/xquery-40/src/back-matter.xml +++ b/specifications/xquery-40/src/back-matter.xml @@ -55,7 +55,15 @@ -Operator Mapping

The operator mapping tables in this section list the +Operator Mapping + + + The operator mapping table has been simplified by removing entries for the operators ne, + le, gt, and ge; these are now defined by reference to the + rules for the operators eq and lt. + + +

The operator mapping tables in this section list the combinations of types for which various operators of &language; are defined. The operators covered by this appendix are the value comparison operators eq and lt, and the arithmetic operators @@ -1588,7 +1596,10 @@ See Change Log + + + diff --git a/specifications/xquery-40/src/conformance.xml b/specifications/xquery-40/src/conformance.xml index 023c7c681..f4e4cd926 100644 --- a/specifications/xquery-40/src/conformance.xml +++ b/specifications/xquery-40/src/conformance.xml @@ -1,6 +1,12 @@ Conformance + + + + Support for higher-order functions is now a mandatory feature (in 3.1 it was optional). + + diff --git a/specifications/xquery-40/src/ebnf.xml b/specifications/xquery-40/src/ebnf.xml index 42a94b35f..a38bf4d9f 100644 --- a/specifications/xquery-40/src/ebnf.xml +++ b/specifications/xquery-40/src/ebnf.xml @@ -358,6 +358,12 @@ Lexical structure + + + + The rules for tokenization have been largely rewritten, without any intended change to the actual behavior. + +

The terminal symbols assumed by the grammar above are described in this section.

Quoted strings appearing in production rules are terminal symbols.

Other terminal symbols are defined in .

diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index 834e3948d..96ca0565d 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -1141,6 +1141,13 @@ items that would result from calling the fn:collection function wit Dynamic Context + + + + The concept of the context item has been generalized, so it is now a context value. That is, + it is no longer constrained to be a single item. + +

The dynamic @@ -2848,6 +2855,16 @@ would raise an error because it has an id child whose value is not Guarded Expressions + + + + The rules for “errors and optimization” have been tightened up to disallow + many cases of optimizations that alter error behavior. In particular + there are restrictions on reordering the operands of and and or, + and of predicates in filter expressions, in a way that might allow the processor to raise dynamic + errors that the author intended to prevent. + +

An expression E is said to be guarded by some governing condition C if evaluation of E is not allowed to fail with a except when C applies.

@@ -2966,6 +2983,15 @@ would raise an error because it has an id child whose value is not Implausible Expressions + + + The rules for reporting type errors during static analysis have been changed + so that a processor has more freedom to report errors in respect of constructs that + are evidently wrong, such as @price/@value, even though dynamic evaluation + is defined to return an empty sequence rather than an error. + + +

Certain expressions, while not erroneous, are classified as being implausible, because they achieve no useful effect.

@@ -4360,6 +4386,13 @@ the schema type named us:address.

Choice Item Types + + + Choice item types (an item type allowing a set of alternative item types) + are introduced. + + +

A choice item type defines an item type that is the union of a number of alternatives. For example the type @@ -4414,6 +4447,12 @@ the schema type named us:address.

Enumeration Types + + Enumeration types are added as a new kind of ItemType, constraining + the value space of strings. + + +

An EnumerationType accepts a fixed set of string values.

@@ -4476,6 +4515,17 @@ the schema type named us:address.

Node Types + + + Element and attribute tests can include alternative names: element(chapter|section), + attribute(role|class). + + + The NodeTest in an AxisStep now allows alternatives: + ancestor::(section|appendix) + + +

Some of the constructs described in this section include a TypeName. This appears as T in:

@@ -4609,6 +4659,14 @@ the schema type named us:address.

Element Test + + + + Element and attribute tests of the form element(N) + and attribute(N) now allow N to be any NameTest, + including a wildcard. + + @@ -4910,6 +4968,14 @@ in the following two situations: Attribute Test + + + + Element and attribute tests of the form element(N) + and attribute(N) now allow N to be any NameTest, + including a wildcard. + + @@ -5440,6 +5506,16 @@ name.

Record Test + + + + Record types are added as a new kind of ItemType, constraining + the value space of maps. + + + The syntax record(*) is allowed; it matches any map. + + @@ -5887,6 +5963,12 @@ name.

Subtype Relationships + + + The presentation of the rules for the subtype relationship between + sequence types and item types has been substantially + rewritten to improve clarity; no change to the semantics is intended. +

Given two sequence types @@ -6885,6 +6967,17 @@ name.

Coercion Rules + + + + The term "function conversion rules" used in 3.1 has been replaced by the term "coercion rules". + + + The coercion rules allow “relabeling” of a supplied atomic value where + the required type is a derived atomic type: for example, it is now permitted to supply + the value 3 when calling a function that expects an instance of xs:positiveInteger. + +

Function Coercion + + + + Function coercion now allows a function with arity N to be supplied where a function of arity + greater than N is expected. For example this allows the function true#0 + to be supplied where a predicate function is required. + + + It has been clarified that function coercion applies even when the supplied function item + matches the required function type. This is to ensure that arguments supplied when calling + the function are checked against the signature of the required function type, which might + be stricter than the signature of the supplied function item. + +

Function coercion is a transformation applied to Numeric Literals + + + Numeric literals can now be written in hexadecimal or binary notation; + and underscores can be included for readability. + + + @@ -8287,6 +8401,12 @@ At evaluation time, the value of a variable reference is the value to which the Filter Expressions + + + The value of a predicate in a filter expression can now be a sequence of integers. + + + @@ -8431,7 +8551,7 @@ At evaluation time, the value of a variable reference is the value to which the ref="id-unordered-expressions"/>.

- Add entry to changes appendix. + @@ -8476,8 +8596,15 @@ At evaluation time, the value of a variable reference is the value to which the

Static and dynamic function calls are described in the following sections.

+ Static Function Calls + + + In a static function call, arguments can be specified either positionally or by keyword, + or a combination of both. + + - Static Function Calls +

The for an expression includes a set of . Every @@ -8517,11 +8644,16 @@ At evaluation time, the value of a variable reference is the value to which the

The detailed rules for evaluating static function calls and function references are defined in subsequent sections.

- - + Static Function Call Syntax + + + Keyword arguments are allowed on static function calls, as well as positional arguments. + + + @@ -9717,6 +9849,17 @@ return $a("A")]]> Inline Function Expressions + + + + In inline function expressions, the keyword function may be abbreviated + as fn. + + New abbreviated syntax is introduced () + for simple inline functions taking a single argument. + An example is fn { ../@code } + + @@ -10982,6 +11125,14 @@ return if (every $r in $R satisfies $r instance of node()) Implausible Axis Steps + + + The rules for reporting type errors during static analysis have been changed + so that a processor has more freedom to report errors in respect of constructs that + are evidently wrong, such as @price/@value, even though dynamic evaluation + is defined to return an empty sequence rather than an error. + +

Certain axis steps, given an inferred type for the context value, are classified as . During the static analysis phase, a processor may (subject to the rules in @@ -12020,6 +12171,12 @@ the results are the same. Arithmetic Expressions + + + + The symbols × and ÷ can be used for multiplication and division. + +

&language; provides arithmetic operators for addition, subtraction, multiplication, division, and modulus, in their usual binary and unary forms.

@@ -12214,6 +12371,14 @@ course to the use of parentheses. Therefore, the following two examples have dif
String Templates + + + + String templates provide a new way of constructing strings: for example `{$greeting}, {$planet}!` + is equivalent to $greeting || ', ' || $planet || '!' + + + @@ -12535,6 +12700,16 @@ must be followed; thus < must be written as Value Comparisons + + + + The rules for value comparisons when comparing values of different types (for example, decimal and double) + have changed to be transitive. A decimal value is no longer converted to double, instead the double is converted + to a decimal without loss of precision. This may affect compatibility in edge cases involving comparison of + values that are numerically very close. + + +

The value comparison operators are eq, ne, lt, le, gt, and ge. Value comparisons are used for comparing single values.

The first step in evaluating a value comparison is to evaluate its operands. The order in which the operands are evaluated is .

General Comparisons + + + + Operators such as < and > can use the full-width forms + and to avoid the need for XML escaping. + +

The general comparison operators are =, !=, <, <=, >, and >=. General comparisons are existentially quantified comparisons that may be applied to operand sequences of any length. The result of a general comparison that does not raise an error is always true or false.

@@ -15491,6 +15673,21 @@ element because it is defined by a For Expressions + + + A for member clause is added to FLWOR expressions to allow iteration over + an array. + + Multiple for and let clauses can be combined + in an expression without an intervenint return keyword. + + + A positional variable can be defined in a for expression. + + + The type of a variable used in a for expression can be declared. + +

XPath provides an iteration facility called a for expression. It can be used to iterate over the items of a sequence, or the @@ -15687,6 +15884,16 @@ return $line/value]]> Let Expressions + + + + Multiple for and let clauses can be combined + in an expression without an intervenint return keyword. + + + The type of a variable used in a let expression can be declared. + +

XPath allows a variable to be declared and bound to a value using a let expression.

@@ -15823,6 +16030,13 @@ processing with JSON processing.

Map Constructors + + + + In map constructors, the keyword map is now optional, so + map { 0: false(), 1: true() } can now be written { 0: false(), 1: true() }. + +

A Map is created using a MapConstructor.

@@ -16237,6 +16451,11 @@ processing with JSON processing.

Lookup Expressions for Maps and Arrays + + The lookup operator ? can now be followed by a string literal, for cases where + map keys are strings other than NCNames. It can also be followed by a variable + reference. + A deep lookup operator ?? is provided for searching trees of maps and arrays. @@ -17661,6 +17880,17 @@ let $z := g($x, $y)]]> For Clause + + + A for member clause is added to FLWOR expressions to allow iteration over + an array. + + + The value bound to a variable in a for clause is now converted + to the declared type by applying the coercion rules. + + + @@ -17978,6 +18208,13 @@ for member $y in $expr2]]> Let Clause + + + + The value bound to a variable in a let clause is now converted + to the declared type by applying the coercion rules. + + @@ -18006,6 +18243,14 @@ let $e := doc("emps.xml")/emps/emp[deptno eq $d]]]> Window Clause + + + + The start clause in window expressions has become optional, as well as + the when keyword and its associated expression. + + + @@ -18616,6 +18861,14 @@ return $x While Clause + + + + A FLWOR expression may now include a while clause, + which causes early exit from the iteration when a condition is encountered. + + + @@ -19614,6 +19867,14 @@ Also, within a Conditional Expressions + + + + Alternative syntax for conditional expressions is available: if (condition) {X} else {Y}, + with the else part being optional. + + +

&language; allows conditional expressions to be written in several different ways.

@@ -19760,6 +20021,14 @@ named discounted, independently of its value:

Otherwise Expressions + + + + An otherwise operator is introduced: A otherwise B returns the + value of A, unless it is an empty sequence, in which case it returns the value of B. + + + @@ -19788,6 +20057,20 @@ named discounted, independently of its value:

Switch Expressions + + + + Switch expressions now allow a case clause to match multiple atomic values. + + + Switch and typeswitch expressions can now be written with curly braces, + to improve readability. + + + The comparand expression in a switch expression can be omitted, allowing + the switch cases to be provided as arbitrary boolean expressions. + + @@ -20435,6 +20718,14 @@ matching
; otherwise it returns false. For example:

Typeswitch + + + + Switch and typeswitch expressions can now be written with curly braces, + to improve readability. + + + @@ -21228,6 +21519,12 @@ raised Mapping Arrow Expressions + + + The arrow operator => is now complemented by a “mapping arrow” operator =!> + which applies the supplied function to each item in the input sequence independently. + +

diff --git a/specifications/xquery-40/src/introduction.xml b/specifications/xquery-40/src/introduction.xml index d52fd8c57..ca75e445e 100644 --- a/specifications/xquery-40/src/introduction.xml +++ b/specifications/xquery-40/src/introduction.xml @@ -2,6 +2,11 @@ Introduction + + + Use the arrows to browse significant changes since the 3.1 version of this specification. + Sections with significant changes are marked Δ in the table of contents. +

As increasing amounts of information are stored, exchanged, and presented using XML, the ability to intelligently query XML data sources becomes increasingly important. One diff --git a/specifications/xquery-40/src/query-prolog.xml b/specifications/xquery-40/src/query-prolog.xml index 294bafc6b..50e4e387e 100644 --- a/specifications/xquery-40/src/query-prolog.xml +++ b/specifications/xquery-40/src/query-prolog.xml @@ -475,6 +475,20 @@ return ( Schema Import + + + + In previous versions the interpretation of location hints in + import schema declarations was entirely at the discretion of the processor. To + improve interoperability, XQuery 4.0 recommends (but does not mandate) + a specific strategy for interpreting these hints. + The rules for the consistency of schemas imported by different query modules, + and for consistency between imported schemas and those used for validating input documents, have + been defined with greater precision. It is now recognized that these schemas will not always be + identical, and that validation with respect to different schemas may produce different outcomes, + even if the components of one are a subset of the components of the other. + + @@ -867,6 +881,14 @@ $triangle Namespace Declaration + + + + All implementations must now predeclare the namespace prefixes + math, map, array, and err. In XQuery 3.1 it was permitted + but not required to predeclare these namespaces. + + @@ -949,6 +971,14 @@ return $node/xx:bing]]> Default Namespace Declaration + + + + The can now be declared to be fixed + for a query module, meaning it is unaffected by a namespace declaration appearing on a direct + element constructor. + + @@ -1104,6 +1134,15 @@ return $node/xx:bing]]> Variable Declaration + + + + The coercion rules are now used when binding values to variables (both + global variable declarations and local variable bindings). This aligns XQuery with XSLT, + and means that the rules for binding to variables are the same as the rules for binding + to function parameters. + + @@ -1339,6 +1378,13 @@ declare function local:f() { $b }; Context Value Declaration + + + + The concept of the context item has been generalized, so it is now a context value. That is, + it is no longer constrained to be a single item. + + @@ -1476,6 +1522,15 @@ declare context value as document-node()* := collection($uri); Function Declarations + + + + Function definitions in the static context may now have optional parameters, + provided this does not cause ambiguity across multiple function definitions with the same name. + Optional parameters are given a default value, which can be any expression, including one that + depends on the context of the caller (so an argument can default to the context value). + +

In addition to the system functions, XQuery allows users to declare functions of their own. A function declaration declares a family of functions having the same name and similar parameters. The declaration specifies the name of @@ -1718,6 +1773,12 @@ local:summary(doc("acme_corp.xml")//employee[location = "Denver"]) Function Annotations + + + The values true() and false() are allowed + in function annotations, and negated numeric literals are also allowed. + +

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