Page 1 of 1

Using XQuery 3.1 with output methods adpative or json

Posted: Sun Feb 24, 2019 1:42 pm
by Martin Honnen
Using the recent oXygen 21 release, I had hoped there is now a way to use XQuery 3.1 with any of the installed Saxon 9.8.0.12 engines (i.e. HE, PE, EE) to make use of XQuery 3.1 directives like

Code: Select all


declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'adaptive';
and then be able to have the result be serialized according the declared output method.

However, whatever I try, I either get some wrong result (for a simple arrray

Code: Select all


declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'adaptive';

[1, 2, 3, 4]
) with "present as sequence" I get only the array items output as

Code: Select all


1

2

3

4
instead of the

Code: Select all

[1,2,3,4]
Saxon gives from the command line.

And when I try show result in editor I get an error
System ID: C:\SomePath\array-literal1.xq
Scenario: array-literal11
XQuery file: C:\SomePath\array-literal1.xq
Engine name: Saxon-HE XQuery 9.8.0.12
Severity: error
Description: Wrapped output: cannot display a function item

Is there some way to use the Saxon XQuery engines installed within oXygen 21 in a XQuery transformation scenario to have them use and apply the serialization methods "adapative" or "json" declared in the query code?

Re: Using XQuery 3.1 with output methods adpative or json

Posted: Mon Feb 25, 2019 4:31 pm
by tavy
Hello Martin,

The Saxon engine generates the output correctly, depending on the output method that you have specified in the XQuery file.

To display this result in Oxygen, you need to specify in the XQuery transformation scenario how you want to see the result. If you select "Present as sequence", the result is presented in the "Sequence" view as a serialization of the resulted nodes.

Therefore, you need to uncheck "Present as sequence" and select to save the result in a file (for example "output.json") and open the file in the editor. If you don't want to save the result in a file you can present it in the XML results view by selecting "Show in results view as XML". The result will be generated correctly depending on the output method, but the syntax highlight will be for XML documents.

Oxygen does not have a view to present the output depending on the method specified in the XQuery file, I will add an issue to improve this support.

Best Regards,
Octavian

Re: Using XQuery 3.1 with output methods adpative or json

Posted: Tue Feb 26, 2019 11:33 am
by Martin Honnen
Somehow I don't get it to work, even as you described it.

I have created a new project to test it with <oXygen/> XML Editor 21.0, build 2019022207, there I now have an XQuery file simply returning an array literal

Code: Select all


declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace array = "http://www.w3.org/2005/xpath-functions/array";

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'adaptive';

[1, 2, 3, 4]
and when executed with Saxon 9.8.0.12 HE XQuery and the output option "show in results view as XML" I only get an error

System ID: C:\SomePath\xquery\array-literal1.xq
Scenario: array-literal1
XQuery file: C:\SomePath\xquery\array-literal1.xq
Engine name: Saxon-HE XQuery 9.8.0.12
Severity: error
Description: Wrapped output: cannot display a function item


The other option to provide an output file name and have that opened in the editor also gives

System ID: C:\SomePath\xquery\array-literal1.xq
Scenario: array-literal1 to file
XQuery file: C:\SomePath\xquery\array-literal1.xq
Engine name: Saxon-HE XQuery 9.8.0.12
Severity: error
Description: Wrapped output: cannot display a function item


Any idea which setting could be wrong?

Re: Using XQuery 3.1 with output methods adpative or json

Posted: Tue Feb 26, 2019 12:56 pm
by tavy
Hi Martin,

The error seems to be generated because in the Options->Preferences-"XML / XSLT-XQuery / XQuery" options page you have the "Create structure indicating the type nodes" option set. Maybe we do not need to use this option when the output method is not xml.

Best Regards,
Octavian