ligasgr / intellij-xquery

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

Specify language version to run using given data source #147

Open sofiageo opened 8 years ago

sofiageo commented 8 years ago

I'm almost certain I'm doing something wrong. But I don't know what that is. I'm trying to run Saxon with parameter -qversion:1.0 so my test script that is using 3.0 features will fail.

But it doesn't fail. I don't care about having highlighting about this, I just want it to fail when I try to run it. Shouldn't this be possible if I passed the argument to the Saxon processor? I can easily do this in eclipse for example. Thanks

(I'm using the latest xquery plugin released today - thanks about that - with Intellij 15.0 on Linux)

ligasgr commented 8 years ago

Hi,

The mechanism for running XQuery files using Saxon in Eclipse is completely different from the mechanism in IntelliJ and is based on the command line options provided by Saxon itself. I tried looking up the flag that you mentioned but cannot find it anywhere. Would you be able to provide me with some more information on documentation of that flag?

Thanks!

sofiageo commented 8 years ago

Hi. The command line flag can be found here

-qversion:(1.0|3.0) Specifies the XQuery language version supported. From Saxon 9.6, the default is 3.0.

For the s9api there is a configuration here From what I understand from this page, it may be possible to use the same configuration for XQJ. I will try to see if it's possible by setting a configuration, then make another comment here. Thanks

sofiageo commented 8 years ago

I managed to create a configuration file - tweaked the sample config file from here. When I set the xquery version to 1.0 in the config file, I get an error if I try to use any xquery 3.0 function. I'm also running the same functions from the command line and get identical errors.

I have also realized that if I set the first line of my xquery script to xquery version "1.0";

It will throw an error while parsing some xquery 3.0 functions, but not for everything. This also happens when running from the command line. I have also realized there are functions that fail in Zorba for xquery 1.0, also fail in older Saxon versions, but will not fail in latest Saxon for xquery 1.0. Specifically something like this:

 declare namespace ns = "ns";
 declare variable $test := <div><ns:elem>1</ns:elem></div>;
 declare function local:test() {
    let $x := $test/*[node-name() = QName("ns","elem")]
    return empty($x)
};

node-name() will fail in some processors for xquery 1.0, but not for others.

[XPST0017] "node-name": function only available in XQuery 3.0

Anyway, all this has nothing to do with the plugin. It seems it's just how it is for the processors.

So the only thing I would suggest now is if it is possible to automatically pick up the declaration of xquery version from the first line, and if it is version 1.0, pass this option to Saxon via -qversion:1.0. If not possible, maybe a simple checkbox to add this functionality in the data source. Thanks

ligasgr commented 8 years ago

Hey,

I'll add a configuration option for data sources of implementations that support it to specify the version of implementation that you want to use (regardless of the version specified in the file).