From 55190b2d6f7b722f48f3739f5fd53461a7c45e51 Mon Sep 17 00:00:00 2001 From: Michael Kay Date: Sun, 27 Oct 2024 19:40:33 +0000 Subject: [PATCH] Actions QT4CG-095-01 and -02 --- specifications/grammar-40/xpath-grammar.xml | 4 +- specifications/xquery-40/src/back-matter.xml | 148 +------------------ specifications/xquery-40/src/ebnf.xml | 2 +- specifications/xquery-40/src/expressions.xml | 29 +++- 4 files changed, 36 insertions(+), 147 deletions(-) diff --git a/specifications/grammar-40/xpath-grammar.xml b/specifications/grammar-40/xpath-grammar.xml index e10dc65aa..685b59159 100644 --- a/specifications/grammar-40/xpath-grammar.xml +++ b/specifications/grammar-40/xpath-grammar.xml @@ -2426,11 +2426,11 @@ ErrorVal ::= "$" VarName - + - + diff --git a/specifications/xquery-40/src/back-matter.xml b/specifications/xquery-40/src/back-matter.xml index 0195e9f75..7bd0fff2d 100644 --- a/specifications/xquery-40/src/back-matter.xml +++ b/specifications/xquery-40/src/back-matter.xml @@ -1501,6 +1501,14 @@ See in 3.1, but will output "1621" (1234 in base 9) with 4.0. As a workaround, this can be rewritten as format-integer(1234, "0^000").

+

In computed node constructors, the node name must now be written in quotation marks + if it matches certain language keywords. For example element div {} must now be + written element "div" {}. (Alternatively, element {"div"} {} + and element Q{}div {} are permitted by both XQuery 3.1 and XQuery 4.0.) + This change is made because {} is now a valid expression representing an + empty map, so expressions such as element otherwise {} could (without this rule) be + parsed in two different ways.

+

In &language;, certain expressions are classified as : an example is @code/text(), which will always return an empty sequence. A processor may report a static error when such expressions are encountered; however, processors are required @@ -1584,145 +1592,5 @@ See - diff --git a/specifications/xquery-40/src/ebnf.xml b/specifications/xquery-40/src/ebnf.xml index 290de7868..f68f6f179 100644 --- a/specifications/xquery-40/src/ebnf.xml +++ b/specifications/xquery-40/src/ebnf.xml @@ -199,7 +199,7 @@ /, on the other hand, is syntactically valid without parentheses.

- + unreserved-name

In a computed node constructor of the form element NNN {}, attribute NNN {}, diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index 70f44db99..54fbf1a3c 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -15085,12 +15085,11 @@ be created: element, attribute, processing-instruction, comment, or namespace.

-

For those kinds of nodes that have names (element, attribute, and -processing instruction nodes), the keyword that specifies the node +

For those kinds of nodes that have names (element, attribute, +processing instruction, and namespace 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. When an expression is used to specify the name of a constructed node, that expression is called the name expression of the @@ -15111,6 +15110,28 @@ same result as the first example in + +

XQuery 4.0 allows the node name to be written in quotation + marks (for example, element "book" {}, and at the same + time it disallows the use of a defined set of language keywords + without quotes: for example element div {} was allowed + in XQuery 3.1 but must now be written element "div" {} or + element {"div"} {}. The reason for this incompatible + change is that allowing map constructors to omit the map + keyword would otherwise create an ambiguity: consider for example the + expression element otherwise {}.

+ +

Because the list of reserved keywords may be extended in future + versions of this specification, the safest strategy is to always to + use quotation marks (for example element "div") + when the node name is a simple NCName. To avoid + any dependency on the default namespace context, the form + element Q{}div might also be used.

+ +

To write code that is portable between XQuery 3.1 and XQuery 4.0, + the best advice is to use either the form element {"div"} + or the form element Q{}div.

+ Computed Element Constructors