<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>6927</bug_id>
          
          <creation_ts>2009-05-20 15:22:26 +0000</creation_ts>
          <short_desc>XQuery 1.1 is not an LL(k) language because of the optional &quot;outer&quot; keyword</short_desc>
          <delta_ts>2009-09-17 20:30:10 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 3.0</component>
          <version>Working drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>needsDrafting</keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gabriel Petrovay">gabriel.petrovay</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>mike</cc>
    
    <cc>nikolay.ognyanov</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>25221</commentid>
    <comment_count>0</comment_count>
    <who name="Gabriel Petrovay">gabriel.petrovay</who>
    <bug_when>2009-05-20 15:22:26 +0000</bug_when>
    <thetext>Hi all,

XQuery 1.1 is not an LL(k) language because of the optional &quot;outer&quot; keyword (yes I know XQuery has no keywords).

Take the following 2 correct queries:

1.
for $x in outer for $y in Expr return 2

2.
for $x in outer for $y in Expr return 2 return 3


The parser has a problem when parsing the &quot;outer for&quot; token sequence because it does not know which production to take next because of the OPTIONAL &quot;outer&quot; keyword. Is it a nested &quot;outer for&quot; or the &quot;outer&quot; step expression followed by a simple &quot;for&quot; clause?

Of course that, by reading the whole input you can determine if the expression is correct, but the language is not anymore an LL(k) one. This is because for any k &gt; 0, one can find an expression (Expr) having [number of tokens] &gt; k such that the parser cannot parse the language.

Regards,
Gabriel</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25232</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-05-20 19:45:26 +0000</bug_when>
    <thetext>Good catch, I think you are right.

Perhaps we could use &quot;outerfor&quot; as a single word.

Though I really wonder how many people understand this &quot;outer&quot; terminology anyway? Not all our users have done a computer science SQL course, and even those who have might not immediately see the relevance. It seems very obscurely related to the actual semantics. Might something like

for $x emptiable? in EXPR

be better?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25238</commentid>
    <comment_count>2</comment_count>
    <who name="Gabriel Petrovay">gabriel.petrovay</who>
    <bug_when>2009-05-20 19:53:16 +0000</bug_when>
    <thetext>Hi Mike,

I had several SQL computer science courses but &quot;emptiable&quot; doesn&apos;t sound familiar to me. &quot;Outer&quot; is a good word. It is also similar to most JOIN terminology for SQL languages. It is just that the syntax must be corrected in my opinion.

Cheers,
Gabriel
28msec.com</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25239</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-05-20 20:05:27 +0000</bug_when>
    <thetext>&gt;I had several SQL computer science courses but &quot;emptiable&quot; doesn&apos;t sound familiar to me. &quot;Outer&quot; is a good word. It is also similar to most JOIN terminology for SQL languages.

Perhaps you misread my point: I was suggesting that the concept of &quot;outer join&quot;, and its relationship to the semantics of FLOWR expressions, would only be understood by those with an advanced computer science education, whereas &quot;emptiable&quot; might be more accessible/memorable to the masses.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26366</commentid>
    <comment_count>4</comment_count>
    <who name="Nikolay Ognyanov">nikolay.ognyanov</who>
    <bug_when>2009-08-10 22:18:01 +0000</bug_when>
    <thetext>*** Bug 7257 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26649</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2009-08-25 13:14:18 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Good catch, I think you are right.
&gt; 
&gt; Perhaps we could use &quot;outerfor&quot; as a single word.
&gt; 
&gt; Though I really wonder how many people understand this &quot;outer&quot; terminology
&gt; anyway? Not all our users have done a computer science SQL course, and even
&gt; those who have might not immediately see the relevance. It seems very obscurely
&gt; related to the actual semantics. Might something like
&gt; 
&gt; for $x emptiable? in EXPR
&gt; 
&gt; be better?


The word &quot;outer&quot; does not really play a role in these semantics as they are defined in the specification. The semantics of the expression are

&quot;If the binding sequence contains no items, the output tuple stream depends on the presence or absence of the outer keyword. If outer is specified, the output tuple stream consists of one tuple in which the variable is bound to an empty sequence. If outer is not specified, the output tuple stream consists of zero tuples.&quot;

It would be nice to have a syntax that reflects these semantics more directly, specifying what to do if the binding sequence is empty. I&apos;m not sure &quot;emptiable&quot; does that. 

I can&apos;t think of a beautiful syntax that does. Perhaps:

for $x in EXPR or empty

Or use a ? after the expression to indicate that empty is allowed:

for $x in EXPR?

We might allow () or any other value to be specified as a parameter, to be used of the binding expression is empty:

for $x in EXPR or ()

Or (more verbose but more explicit):

for $x in EXPR on empty () 

Regardless, I agree with Mike Kay that &quot;outer&quot; is not helpful in this syntax.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26652</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-08-25 13:27:38 +0000</bug_when>
    <thetext>for $x in EXPR even when empty ... ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27264</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2009-09-17 20:30:10 +0000</bug_when>
    <thetext>On July 7th, the Working Group agreed to replace &quot;outer for&quot; with &quot;for ... allowing empty&quot;, where &quot;allowing empty&quot; comes between TypeDeclaration? and PositionalVar?.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>