This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 5632 - [UPD] Update primitives should be error-free
Summary: [UPD] Update primitives should be error-free
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Update Facility (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Andrew Eisenberg
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-07 17:20 UTC by Michael Kay
Modified: 2008-05-20 23:50 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2008-04-07 17:20:46 UTC
Generally, the XQuery update specification is written so that dynamic errors are detected as early as possible: either when the updating expression itself is evaluated, or when testing the consistency of the updates within the Pending Update List. There are two exceptions, errors that are described as occurring during the application of update primitives.

The first is in upd:delete: "If $target has no parent, the XDM instance is unchanged. An implementation may (but is not required to) raise a dynamic error if $target had no parent before execution of the query began. [err:XUDY0020]." This error condition belong much more naturally in the rules for the delete expression (and indeed it is mentioned there, though only in a Note).

The second is XUDY0024. This occurs when two update primitives in the PUL would cause conflicting namespace bindings to be added to the same element. (It is phrased as if it also occurs when a new namespace binding conflicts with a namespace binding that was there before the update started, but in fact all such cases are caught earlier, as XUDY0023.) XUDY0024 can be expressed as a consistency constraint on the content of the pending update list. All other such constraints are described in the rules for upd:mergeUpdates and upd:applyUpdates. 

Does this make any operational difference? In the absence of try/catch, perhaps not. But with try/catch it becomes significant which expression has failed, and an error described under upd:mergeUpdates() can be raised during the evaluation of the expression that caused a primitive to be added to the PUL. Also, of course, some implementations may find it helpful to perform all the consistency checks on the PUL before applying any updates, as this makes it easier to achieve atomicity; it would therefore be helpful to readers to describe XUDY0024 as a constraint on the consistency of the PUL.

The error could be described like this (in 3.2.1 and 3.2.2):

e. Multiple namespace bindings are created for the same element by primitives on (the merged list | $pul), such that two or more such namespace bindings have the same prefix (or absence of a prefix) and different namespace URIs. Primitives that create a namespace binding are:

  i. upd:insertAttributes creates one namespace binding on the $target element corresponding to the *implied namespace binding* of each attribute node in $content

  ii. upd:replaceNode creates one namespace binding on the $target element corresponding to the *implied namespace binding* of each attribute node in $replacement

  iii. upd:rename creates a namespace binding on $target, or on the parent of $target if $target is an attribute node, corresponding to the *implied namespace binding* of $newName.
Comment 1 zhen hua liu 2008-04-15 17:19:24 UTC
These are the comments collected from the "XML Query/XSL WG Joint Teleconference 363 Agenda 2008-04-15"
(1) In xquery update facility, the snapshot for application of update is the top level expression, not individual expressions smaller than the top level expression. Therefore, one can not use try/catch (with the current 1.1 try/catch proposals) to catch errors from applicatin of PUL other than the top level expression. For example, if you have a comma expression, each child of a comma expression is a try-catch on an updating expression, the try-catch can not catch errors from the applications of PUL.
(2) Implementations is free to do optimizations by detecting potential errors from application of PUL early on. However, it should do so as if the application of PUL were done when the top level expression snapshot ended. Otherwise, the optimization is not correct. Performing all the consistency checks on the PUL before applying any updates is an optimization issue, not spec issue.
Comment 2 Don Chamberlin 2008-05-20 23:50:18 UTC
The Query Working Group considered this bug report on 20 May 2008 and agreed to make the changes suggested by Michael Kay. These changes will cause errors XUDY0020 and XUDY0024 to be more closely associated with a specific
expression. Since Michael participated in the discussion, I am marking this bug report as Closed.
--Don Chamberlin (for the Query Working Group)