Bug 19626 - [XQ31] Awkward option declarations
[XQ31] Awkward option declarations
Status: REOPENED
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.1
Working drafts
PC Windows NT
: P2 normal
: ---
Assigned To: Jonathan Robie
Mailing list for public feedback on specs from XSL and XML Query WGs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-19 08:55 UTC by Tim Mills
Modified: 2012-10-30 09:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Mills 2012-10-19 08:55:29 UTC
Consider the following query.

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

declare function local:foo() as schema-element(s:foo) 
{
 ...
}

declare option prohibit-feature "schema-aware";

local:foo()


It is not until we are well into parsing that the option prohibiting use of import schema is encountered.  This is quite annoying.


Consider also a processor which has schema awareness disabled by default.

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

declare function local:foo() as schema-element(s:foo) 
{
 ...
}

declare option require-feature "schema-aware";

local:foo()

It is not until we are well into parsing that the option enabling use of import schema is encountered.  This is similarly annoying.
Comment 1 Michael Kay 2012-10-19 09:08:13 UTC
Another example of the same effect occurs when the higherOrderFunction feature is disabled after a function or variable declaration that makes use of it.

However, I'm inclined to live with it. In general, we allow forwards references; it's a hassle for implementors, but that's the job that implementors are paid for.
Comment 2 Tim Mills 2012-10-19 09:16:19 UTC
There's also a usability issue.  It's natural to write the require/prohibit before the feature is used - but this is grammatically incorrect.

Other examples include use of validate expressions in a function, or use of fn:serialize with serialization disabled.

That means it's awkward for every XQuery 3.0-defined feature except static typing.
Comment 3 Tim Mills 2012-10-19 11:02:05 UTC
Additionally, I don't find this construct particularly intuitive.

Without a detailed reading of the specification, I'd expect:

      declare option prohibit-feature "higher-order-function";
      declare option require-feature "all-optional-features";

either 

a) to complain that the higher-order-function feature is both prohibited and required (since higher-order-function is in the set of all optional features), OR
b) to disable the higher-order-function feature and then re-enable it.
Comment 4 Jonathan Robie 2012-10-29 15:51:26 UTC
The Working Group has decided not to change this in XQuery 3.0. Feel free to open this against 3.1 as a potential requirement.
Comment 5 Tim Mills 2012-10-30 09:54:16 UTC
Reopening as a potential change for XQuery 3.1.

I suggest something along the lines of

[6]    	Prolog 	   ::=    	
((DefaultNamespaceDecl | NamespaceDecl) Separator)* 
((OptionDecl) Separator)*
((DefaultNamespaceDecl | Setter | NamespaceDecl | Import) Separator)* 
((ContextItemDecl | AnnotatedDecl | OptionDecl) Separator)*

to permit option declarations to appear before schema/module imports.