ligasgr / intellij-xquery

Plugin to support XQuery in Intellij Idea
Apache License 2.0
35 stars 23 forks source link

Error messages should be generated for statements within a for loop not in FLOWR order. #153

Closed rhdunn closed 8 years ago

rhdunn commented 8 years ago

Given:

for $foo in $bar
    order by $foo
    let $x := $foo/bar
    return $x

The order by line is not flagged with an error, even though the order should be let, order by, where then return.

ligasgr commented 8 years ago

Hey

It is not flagged as an error as it is valid according to all standards. Please have a look at the grammar of the FLWOR expressions (here)[http://www.w3.org/TR/xquery-30/#id-flwor-expressions]. It explicitly says that after initial clause of for/let there is unlimited number of for/let/where/group by/order by/count clauses without any particular order. Please also run expression like

for $foo in (<c><bar>c</bar></c>, <b><bar>b</bar></b>, <a><bar>a</bar></a>)
order by $foo
let $x := $foo/bar
return $x

and see if it works. It works fine in Saxon/Zorba/BaseX and probably some other (I didn't check all of the implementations). If it doesn't that it probably means that your implementation only supports FLWOR expressions from (XQuery 1.0)[http://www.w3.org/TR/xquery/#id-flwor-expressions] whereas the plugin is specifically targeted at version 3.0 of XQuery. In which case you should probably raise a feature request for the implementation that you are using :)