FOTS driver: "declare option hof" in wrong place

Bug #1070704 reported by Chris Hillery
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Sorin Marian Nasoi

Bug Description

This happens at least with prod-SchemaImport / substitution-004, probably many others.

The computed query looks like this (edited) :

import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
   .....
variable $queryID := xqxq:prepare-main-module('
xquery version ''3.0'';

declare namespace op = ''http://www.zorba-xquery.com/options/features'';
declare namespace f = ''http://www.zorba-xquery.com/features'';
declare option op:enable ''f:hof'';

        import schema namespace s="http://www.w3.org/XQueryTest/substitution";

   .....

The problem with this is that "declare option" must occur in the prolog AFTER all declare namespace and import statements. It works if the "declare option" is moved after the "import schema". (Actually the test still fails, but for unrelated reasons - looks like Xerces doesn't like that schema.)

Tags: fots-driver

Related branches

Revision history for this message
Chris Hillery (ceejatec) wrote :

As a note - the "declare option" and associated namespaces are actually not required in the test query at all, at least not in this case. They are needed in the outer query - the one that calls xqxq:prepare-main-module(), but as far as I can tell they don't do anything useful for the test query compiled by XQXQ.

However, presumably in at least some tests (those that test HOF), the "declare option" will be required, so it will have to go after any schema/module imports.

Changed in zorba:
importance: Undecided → High
assignee: nobody → Sorin Marian Nasoi (sorin.marian.nasoi)
milestone: none → 2.8
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

I have committed a partial fix for the reported issue.

The problem with enabling the FOTS feature will be fixed only after the HOF is fully implemented and enabled by default thus not needing the additional "declare option hof".

Please see detail below.

Here is what happens:
wrt.
"As a note - the "declare option" and associated namespaces are actually not required in the test query at all"
Not actually true: as a general rule whenever a test has a dependency on XQuery 3.0, the Zorba FOTS adds both:
- the XQuery 3.0 declaration (if the test does not have it already)
- the "declare option hof"
That is because one does not know if the query actually uses a HOF function thus really needing the "declare option hof" or not.
Checking if the test is using a HOF functionality would be a very time consuming operation because it would have to be done for all tests that have a XQuery 3.0 dependency.
But this would not solve the issue from the reported test case because:

the first part is indeed added by the Zorba FOTS driver:

import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
   .....
variable $queryID := xqxq:prepare-main-module('
xquery version ''3.0'';

declare namespace op = ''http://www.zorba-xquery.com/options/features'';
declare namespace f = ''http://www.zorba-xquery.com/features'';
declare option op:enable ''f:hof'';

and the second part comes from the test itself that can not be changed:
import schema namespace s="http://www.w3.org/XQueryTest/substitution";
[...]

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

I have committed a partial fix for the cases where the "declare option hof" came before the declaration of the variables.

Marking the bug as "Won't fix" for now.

Changed in zorba:
status: New → Won't Fix
Revision history for this message
Chris Hillery (ceejatec) wrote :

I'm afraid we can't "not fix" this one - as far as I can tell, this means that any test which both:

1. requires XQuery 3.0
2. imports a schema

will not work with our FOTS driver, and that is too large a limitation.

Either we need a hack to modify the test case text (inserting "declare option" in the right place), or we need a change at the XQXQ level to enable the option.

Changed in zorba:
status: Won't Fix → Confirmed
tags: added: fots-driver
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

This will be fixed after Nicolai's branch is merged.

That is why I am moving this for next release.

Changed in zorba:
milestone: 2.8 → 3.0
Revision history for this message
Chris Hillery (ceejatec) wrote :

Actually there will probably be a 2.9 too, and hopefully HOF will be there.

Changed in zorba:
milestone: 3.0 → 2.9
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

True, that is why as soon as lp:~nbrinza/zorba/hof is merged this will be fixed.

Changed in zorba:
status: Confirmed → In Progress
Revision history for this message
Nicolae Brinza (nbrinza) wrote :

Declare option hof has been removed.

Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.