[Bug 5332] [UPD] Parentheses around () or fn:error()

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5332

           Summary: [UPD] Parentheses around () or fn:error()
           Product: XPath / XQuery / XSLFO / XSLT
           Version: Last Call drafts
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Update Facility
        AssignedTo: andrew.eisenberg@us.ibm.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


The XQuery Update specification allows the expressions () or fn:error() to
appear in certain contexts where updating expressions may appear. However, it
does not allow the expression () or fn:error() to be enclosed in parentheses in
such contexts. Thus it is OK to write:

if (b)
  then delete node $x
  else fn:error()

But it is wrong to write

if (b)
  then (delete node $x)
  else (fn:error())

This violates the common expectation that any expression can be enclosed in
parentheses without changing its meaning or validity. It makes life
unnecessarily difficult for software that is generating XQuery code (for
example, a stylesheet that generates XQuery from XQueryX), and it also makes
life unnecessarily difficult for people implementing XQuery parsers, because
they have to retain some representation of redundant parentheses in the
expression tree until after semantic checks have been performed.

The problem can be solved by partitioning expressions into three categories
instead of two: updating, non-updating, and neutral. The expressions () and
fn:error() should fall into the neutral category, and a parenthesized
expression should have (as now) the same category as its content. Contexts that
currently allow an updating expression or () or fn:error() should allow any
updating or neutral expression. (And of course, places that require a
non-updating expression should now require a non-updating or neutral
expression)

I would suggest that fn:trace() should also be added to the neutral category.

Received on Monday, 31 December 2007 14:46:45 UTC