Errata for XQuery 1.0: An XML Query Language

23 November 2007

Latest version:
http://www.w3.org/XML/2007/qt-errata/xquery-errata.html
Editor:
Don Chamberlin, IBM Almaden Research Center http://www.almaden.ibm.com/

Abstract

This document addresses errors in the XQuery 1.0: An XML Query Language Recommendation published on 23 January 2007. It records all errors that, at the time of this document's publication, have solutions that have been approved by the XSL Working Group and/or the XML Query Working Group. For updates see the latest version of that document.

The errata are numbered, classified as Substantive, Editorial, or Markup, and are listed in reverse chronological order of their date of origin. Each entry contains the following information:

Colored boxes and shading are used to help distinguish new text from old, however these visual clues are not essential to an understanding of the change. The styling of old and new text is an approximation to its appearance in the published Recommendation, but is not normative. Hyperlinks are shown underlined in the erratum text, but the links are not live.

A number of indexes appear at the end of the document.

Substantive corrections are proposed by the XSL Working Group and/or the XQuery Working Group (both part of the XML Activity), which have consensus that they are appropriate; they are not to be considered normative until approved by a Call for Review of Proposed Corrections or a Call for Review of an Edited Recommendation.

Please report errors in this document using W3C's public Bugzilla system (instructions can be found at http://www.w3.org/XML/2005/04/qt-bugzilla). If access to that system is not feasible, you may send your comments to the W3C XSLT/XPath/XQuery public comments mailing list, public-qt-comments@w3.org. It will be very helpful if you include the string [XQerrata] in the subject line of your report, whether made in Bugzilla or in email. Each Bugzilla entry and email message should contain only one error report. Archives of the comments and responses are available at http://lists.w3.org/Archives/Public/public-qt-comments/.

Status of this Document

This is a public draft. None of the errata reported in this document have been approved by a Call for Review of Proposed Corrections or a Call for Review of an Edited Recommendation. As a consequence, they must not be considered to be normative.

Table of Contents

  Errata

     XQ.E10   Clarifies that the default initial static type of the context item is undefined.

     XQ.E9   Specifies that, in a computed attribute constructor, if the QName of the constructed attribute has a namespace URI but no prefix, an implementation-dependent prefix is generated.

     XQ.E8   Deletes error code XQST0073, because it is redundant to error code XQST0093.

     XQ.E7   In Section 3.13 (Validate Expression), Rule 3c, deletes "Identity-constraint Satisfied" from the list of rules that are not applied during validation.

     XQ.E6   Tightens the rules for the in-scope schema definitions that must be present in an importing module.

     XQ.E5   Clarifies the conditions under which a castable expression may raise an error.

     XQ.E4   Adds more details to the rules defining permissible expression rewrites for optimization and other purposes.

     XQ.E3   For valid syntax, adds parentheses to the expansion for leading "/" and leading "//" in a path expression.

     XQ.E2   Reverses the order of Rules 1 and 2 in XQuery Section 3.7.3.1, Computed Element Constructors (processing of content sequence).

     XQ.E1   Specifies that error XQTY0086 applies to copied attribute nodes as well as copied element nodes, including copied attribute nodes that have no parent.

  Indexes

    Index by affected section

    Index by Bugzilla entry

    Index by construct

    Index by error-code


XQ.E10 - editorial

See Bug 5035

Description

Clarifies that the default initial static type of the context item is undefined.

History

27 Sep 2007: Proposed

20 Nov 2007: Accepted

Change

In C.1 Static Context Components (first table, first table body, tenth row, second column):

Replace the text:

none (raises error on access)

By:

Undefined (raises error on access)

XQ.E9 - substantive

See Bug 4443

Description

Specifies that, in a computed attribute constructor, if the QName of the constructed attribute has a namespace URI but no prefix, an implementation-dependent prefix is generated.

History

27 Sep 2007: Proposed

20 Nov 2007: Accepted

Change

In 3.7.3.2 Computed Attribute Constructors (first numbered list, second item):

Replace the text:

2

If the atomized value of the name expression is of type xs:QName, that expanded QName (including its prefix) is used as the node-name property of the constructed attribute node.

By:

2

If the atomized value of the name expression is of type xs:QName:

  1. If the expanded QName returned by the atomized name expression has a namespace URI but has no prefix, it is given an implementation-dependent prefix.

    Note:

    This step is necessary because the default namespace does not apply to attributes. Therefore any attribute name that has a namespace URI must also have a prefix.

  2. The resulting expanded QName (including its prefix) is used as the node-name property of the constructed attribute node.

XQ.E8 - substantive

See Bug 4418

Description

Deletes error code XQST0073, because it is redundant to error code XQST0093.

History

9 Oct 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. Processing

    A module may import its own target namespace (this is interpreted as importing an implementation-defined set of other modules that share its target namespace.)

    No section with id="id-module-imports" found in base document

  2. In F Error Conditions (first error-list, seventy-second error):

    Delete the text:

    err:XQST0073

    It is a static error if the graph of module imports contains a cycle (that is, if there exists a sequence of modules M1 ... Mn such that each Mi imports Mi+1 and Mn imports M1), unless all the modules in the cycle share a common namespace.

XQ.E7 - substantive

See Bug 4353

Description

In Section 3.13 (Validate Expression), Rule 3c, deletes "Identity-constraint Satisfied" from the list of rules that are not applied during validation. This rule must be applied.

History

27 Sep 2007: Proposed

20 Nov 2007: Accepted

Change

In 3.13 Validate Expressions (first numbered list, third item, first numbered list, third item):

Replace the text:

c

If the operand node is an element node, the validation rules named "Validation Root Valid (ID/IDREF)" and "Identity-constraint Satisfied" are not applied. This means that document-level constraints relating to uniqueness and referential integrity are not enforced.

By:

c

If the operand node is an element node, the validation rule named "Validation Root Valid (ID/IDREF)" is not applied. This means that document-level constraints relating to uniqueness and referential integrity are not enforced.

XQ.E6 - substantive

See Bug 4321

Description

Tightens the rules for the in-scope schema definitions that must be present in an importing module. For example, if the imported module contains a function definition that includes a parameter of type schema-element(EN) and that function is referenced in the importing module, then the importing module must have an in-scope element declaration for EN.

History

16 Oct 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. Processing

    It is a static error to import a module if the in-scope schema definitions of the importing module do not include all of the following:

    An in-scope schema type for each type-name that appears:

    in the type of a variable that is declared in the imported module and referenced in the importing module, OR

    in a parameter-type or result-type of a function that is declared in the imported module and referenced in the importing module.

    An in-scope element declaration for each element-name EN such that:

    schema-element(EN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR

    schema-element(EN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.

    An in-scope attribute declaration for each attribute-name AN such that:

    schema-attribute(AN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR

    schema-attribute(AN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.

    No section with id="id-module-imports" found in base document

  2. In F Error Conditions (first error-list, thirty-fifth error):

    Replace the text:

    err:XQST0036

    It is a static error to import a module if the importing module's in-scope schema types do not include definitions for the schema type names that appear in the declarations of variables and functions (whether in an argument type or return type) that are present in the imported module and are referenced in the importing module.

    By:

    err:XQST0036

    It is a static error to import a module if the in-scope schema definitions of the importing module do not include all of the following:

    1. An in-scope schema type for each type-name that appears:

      1. in the type of a variable that is declared in the imported module and referenced in the importing module, OR

      2. in a parameter-type or result-type of a function that is declared in the imported module and referenced in the importing module.

    2. An in-scope element declaration for each element-name EN such that:

      1. schema-element(EN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR

      2. schema-element(EN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.

    3. An in-scope attribute declaration for each attribute-name AN such that:

      1. schema-attribute(AN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR

      2. schema-attribute(AN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.

XQ.E5 - substantive

See Bug 4873

Description

Clarifies the conditions under which a castable expression may raise an error.

History

19 Sep 2007: Proposed

20 Nov 2007: Accepted

Change

In 3.12.4 Castable (second paragraph):

Replace the text:

The expression V castable as T returns true if the value V can be successfully cast into the target type T by using a cast expression; otherwise it returns false. The castable expression can be used as a predicate to avoid errors at evaluation time. It can also be used to select an appropriate type for processing of a given value, as illustrated in the following example:

By:

The expression E castable as T returns true if the result of evaluating E can be successfully cast into the target type T by using a cast expression; otherwise it returns false. If evaluation of E fails with a dynamic error, the castable expression as a whole fails. The castable expression can be used as a predicate to avoid errors at evaluation time. It can also be used to select an appropriate type for processing of a given value, as illustrated in the following example:

XQ.E4 - substantive

See Bug 4446

Description

Adds more details to the rules defining permissible expression rewrites for optimization and other purposes.

History

19 Sep 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. In 2.3.4 Errors and Optimization (twelfth paragraph):

    Replace the text:

    For a variety of reasons, including optimization, implementations are free to rewrite expressions into equivalent expressions. Other than the raising or not raising of errors, the result of evaluating an equivalent expression must be the same as the result of evaluating the original expression. Expression rewrite is illustrated by the following examples.

    By:

    For a variety of reasons, including optimization, implementations may rewrite expressions into a different form. There are a number of rules that limit the extent of this freedom:

    • Other than the raising or not raising of errors, the result of evaluating a rewritten expression must conform to the semantics defined in this specification for the original expression.

      Note:

      This allows an implementation to return a result in cases where the original expression would have raised an error, or to raise an error in cases where the original expression would have returned a result. The main cases where this is likely to arise in practice are (a) where a rewrite changes the order of evaluation, such that a subexpression causing an error is evaluated when the expression is written one way and is not evaluated when the expression is written a different way, and (b) where intermediate results of the evaluation cause overflow or other out-of-range conditions.

      Note:

      This rule does not mean that the result of the expression will always be the same in non-error cases as if it had not been rewritten, because there are many cases where the result of an expression is to some degree implementation-dependent or implementation-defined.

    • Conditional and typeswitch expressions must not raise a dynamic error in respect of subexpressions occurring in a branch that is not selected, and must not return the value delivered by a branch unless that branch is selected. Thus, the following example must not raise a dynamic error if the document abc.xml does not exist:

      if (doc-available('abc.xml')) then doc('abc.xml') else ()
    • As stated earlier, an expression must not be rewritten to dispense with a required cardinality check: for example, string-length(//title) must raise an error if the document contains more than one title element.

    • Expressions must not be rewritten in such a way as to create or remove static errors. For example, there is a rule that in casting a string to a QName the operand must be a string literal. This rule applies to the original expression and not to any rewritten form of the expression.

    Expression rewrite is illustrated by the following examples.

  2. In 2.3.4 Errors and Optimization (second bulleted list, second item, second paragraph):

    Replace the text:

    To avoid unexpected errors caused by expression rewrite, tests that are designed to prevent dynamic errors should be expressed using conditional or typeswitch expressions. Conditional and typeswitch expressions raise only dynamic errors that occur in the branch that is actually selected. Thus, unlike the previous example, the following example cannot raise a dynamic error if @x is not castable into an xs:date:

    By:

    To avoid unexpected errors caused by expression rewrite, tests that are designed to prevent dynamic errors should be expressed using conditional or typeswitch expressions. For example, the above expression can be written as follows:

XQ.E3 - substantive

See Bug 4868

Description

For valid syntax, adds parentheses to the expansion for leading "/" and leading "//" in a path expression.

History

10 Aug 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. In 3.2 Path Expressions (third paragraph):

    Replace the text:

    A "/" at the beginning of a path expression is an abbreviation for the initial step fn:root(self::node()) treat as document-node()/ (however, if the "/" is the entire path expression, the trailing "/" is omitted from the expansion.) The effect of this initial step is to begin the path at the root node of the tree that contains the context node. If the context item is not a node, a type error is raised [err:XPTY0020]. At evaluation time, if the root node above the context node is not a document node, a dynamic error is raised [err:XPDY0050].

    By:

    A "/" at the beginning of a path expression is an abbreviation for the initial step (fn:root(self::node()) treat as document-node())/ (however, if the "/" is the entire path expression, the trailing "/" is omitted from the expansion.) The effect of this initial step is to begin the path at the root node of the tree that contains the context node. If the context item is not a node, a type error is raised [err:XPTY0020]. At evaluation time, if the root node above the context node is not a document node, a dynamic error is raised [err:XPDY0050].

  2. In 3.2 Path Expressions (fourth paragraph):

    Replace the text:

    A "//" at the beginning of a path expression is an abbreviation for the initial steps fn:root(self::node()) treat as document-node()/descendant-or-self::node()/ (however, "//" by itself is not a valid path expression [err:XPST0003].) The effect of these initial steps is to establish an initial node sequence that contains the root of the tree in which the context node is found, plus all nodes descended from this root. This node sequence is used as the input to subsequent steps in the path expression. If the context item is not a node, a type error is raised [err:XPTY0020]. At evaluation time, if the root node above the context node is not a document node, a dynamic error is raised [err:XPDY0050].

    By:

    A "//" at the beginning of a path expression is an abbreviation for the initial steps (fn:root(self::node()) treat as document-node())/descendant-or-self::node()/ (however, "//" by itself is not a valid path expression [err:XPST0003].) The effect of these initial steps is to establish an initial node sequence that contains the root of the tree in which the context node is found, plus all nodes descended from this root. This node sequence is used as the input to subsequent steps in the path expression. If the context item is not a node, a type error is raised [err:XPTY0020]. At evaluation time, if the root node above the context node is not a document node, a dynamic error is raised [err:XPDY0050].

XQ.E2 - substantive

See Bug 3637

Description

Reverses the order of Rules 1 and 2 in XQuery Section 3.7.3.1, Computed Element Constructors (processing of content sequence). Also reverses the order of Rules 1 and 2 in Section 3.7.3.3, Document Node Constructors. These changes are necessary in order to cause document nodes to be replaced by their children before adjacent text nodes are merged.

History

10 Aug 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. In 3.7.3.1 Computed Element Constructors (starting at second numbered list, first item):

    Replace the text:

    1

    Adjacent text nodes in the content sequence are merged into a single text node by concatenating their contents, with no intervening blanks. After concatenation, any text node whose content is a zero-length string is deleted from the content sequence.

    2

    If the content sequence contains a document node, the document node is replaced in the content sequence by its children.

    By:

    1

    If the content sequence contains a document node, the document node is replaced in the content sequence by its children.

    2

    Adjacent text nodes in the content sequence are merged into a single text node by concatenating their contents, with no intervening blanks. After concatenation, any text node whose content is a zero-length string is deleted from the content sequence.

  2. In 3.7.3.3 Document Node Constructors (starting at first numbered list, first item):

    Replace the text:

    1

    Adjacent text nodes in the content sequence are merged into a single text node by concatenating their contents, with no intervening blanks. After concatenation, any text node whose content is a zero-length string is deleted from the content sequence.

    2

    If the content sequence contains a document node, the document node is replaced in the content sequence by its children.

    By:

    1

    If the content sequence contains a document node, the document node is replaced in the content sequence by its children.

    2

    Adjacent text nodes in the content sequence are merged into a single text node by concatenating their contents, with no intervening blanks. After concatenation, any text node whose content is a zero-length string is deleted from the content sequence.

XQ.E1 - substantive

See Bug 4151

Description

Specifies that error XQTY0086 applies to copied attribute nodes as well as copied element nodes, including copied attribute nodes that have no parent. The error is raised when construction-mode calls for the type of a QName to be preserved, but copy-namespaces-mode does not preserve the namespace binding that is needed by the QName.

History

23 Oct 2007: Proposed

20 Nov 2007: Accepted

Changes

  1. In 3.7.1.3 Content (first numbered list, first item, first numbered list, fifth item, first numbered list, second item, first numbered list, fourth item, first numbered list, first item):

    Replace the text:

    I

    If copy-namespaces mode specifies preserve, all in-scope-namespaces of the original element are retained in the new copy. If copy-namespaces mode specifies no-preserve, the new copy retains only those in-scope namespaces of the original element that are used in the names of the element and its attributes. It is a type error [err:XQTY0086] in this case if the typed value of the copied element or of any of its attributes is namespace-sensitive. [Definition] A value is namespace-sensitive if it includes an item whose dynamic type is xs:QName or xs:NOTATION or is derived by restriction from xs:QName or xs:NOTATION.

    Note:

    Error [err:XQTY0086] can occur only if construction mode is preserve, since otherwise the typed value of the copied node is never namespace-sensitive.

    By:

    I

    If copy-namespaces mode specifies preserve, all in-scope-namespaces of the original element are retained in the new copy. If copy-namespaces mode specifies no-preserve, the new copy retains only those in-scope namespaces of the original element that are used in the names of the element and its attributes.

  2. In 3.7.1.3 Content (first numbered list, first item, first numbered list, fifth item, first numbered list, second item, first numbered list, fifth item):

    Insert before the text:

    E

    When an element or processing instruction node is copied, its base-uri property is set to be the same as that of its new parent, with the following exception: if a copied element node has an xml:base<