[Bug 2681] Functions taking "." as default argument

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

           Summary: Functions taking "." as default argument
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators
        AssignedTo: ashok.malhotra@oracle.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


A number of functions, such as local-name(), name(), base-uri() etc default the
first argument to the context item. It might be thought that name() and name(.)
are precisely equivalent; indeed, it might be thought that the function call
name() could be statically rewritten to name(.).

However, the behaviour of the two function calls is different in error cases. If
the context item is not a node, name(.) throws XPTY0004 while name() throws
FOTY0011. If the context item is undefined, name(.) throws XPDY0002 while name()
throws FONC0001.

It's inconvenient for the implementation to have to generate different
executable code for these two constructs just so that different error codes can
be generated at run-time. The distinction doesn't seem particularly helpful to
the user. I propose that the behaviour of name() and similar functions should be
the same as name(.) even in error cases.

Michael Kay

Received on Saturday, 7 January 2006 23:23:46 UTC