XQuery: Ambiguous expression using "context"

Hi,

The expression:
     if (A) then B instance of element C context type else/D
According to precedence rules, should be interpreted the same as:
     if (A) then (B instance of element C context type else/D)
However, this is not a valid expression, since there is no 'else' in if 
expression. The first expression should therefor be interpreted as:
     if (A) then (B instance of element C context type) else (/D)
Where "type" is treated as a QName. This interpretation is a valid 
expression. To Determine which of the two choices must be made information 
is needed about whether an additional "else" statement follows the 
expression. Determining this requires an indeterminate large lookahead, 
since "/D" could be any number of tokens ("/D/E/F/G" etc.)

This problem can also occur with for (and possibly every, some and let)
    for $A as element B context type in /C return D

Solutions to this problem could be:
1. Require parenthesis around type expressions
2. Require parenthesis around in, then, as, where, and maybe more 
expressions
3. Clearly state that the simpler-to-parse rules must be followed, even if 
that leads to syntax errors

Of these solutions I prefer the third, since it does not significantly 
change the language, when this problem would arise (which is quite unlikely) 
parenthesis could always be added.

Twan van Laarhoven

ps. Sorry for the Hotmail spam:

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

Received on Thursday, 23 January 2003 11:20:20 UTC