[Bug 5288] [XQuery] XPST0005 and conditinoal expressions

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

           Summary: [XQuery] XPST0005 and conditinoal expressions
           Product: XPath / XQuery / XSLFO / XSLT
           Version: Recommendation
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery
        AssignedTo: chamberl@almaden.ibm.com
        ReportedBy: tim@cbcl.co.uk
         QAContact: public-qt-comments@w3.org


err:XPST0005 is defined in XQuery as

    During the analysis phase, it is a static error if the static type assigned
to an expression other than the expression () or data(()) is empty-sequence().

Consider the expression:

if (...)
then ()
else fn:error('err:MyError')

The static type of this expression is empty-sequence(), which is the union of
'none' and 'empty-sequence()', as noted in paragraph 2 of 

http://www.w3.org/TR/xquery-semantics/#sec_content_models

According to the definition of XPST0005, this should raise XPST0005 at static
type checking, rather than possibly calling fn:error at run time.  A suitably
constructed typeswitch could also exhibit this behaviour.  Is this intentional?
 A glance at the XQuery Update Facility shows that this is a problem here too,
as the updating operations have static type empty-sequence().

I note that this error is only ever tested in XQTS when a step in a path
expression is found to be empty-sequence() (a case specifically mentioned in
the XQuery specification).  Other than the cases mentioned above, I think it
may also be thrown during static type checking of 'for', 'for/at', 'let',
variable references and function calls.  

Since implementations are allowed to use static type checking extensions (which
might infer a static type of empty-sequence() when the standard rules cannot),
testing of this error code could be quite tricky.

Received on Tuesday, 27 November 2007 13:19:06 UTC