This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 2318 - SequenceType with occurrence in For/Some/Every expr doesn't make sense
Summary: SequenceType with occurrence in For/Some/Every expr doesn't make sense
Status: CLOSED WONTFIX
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 1.0 (show other bugs)
Version: Last Call drafts
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Don Chamberlin
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-28 15:47 UTC by Martin Probst
Modified: 2005-09-29 14:08 UTC (History)
0 users

See Also:


Attachments

Description Martin Probst 2005-09-28 15:47:47 UTC
I think there is a (somewhat minor) bug in the XQuery specification
about sequence type matching. The grammar states:

[34]   ForClause         ::=    <"for" "$"> VarName TypeDeclaration? ...
[118]  TypeDeclaration   ::=    "as" SequenceType
[119]  SequenceType      ::=    (ItemType OccurrenceIndicator?)
                                | <"empty-sequence" "(" ")">

and similar rules for Some, Every and Let. I think these rules should
rather reference/descend directly into ItemType (or in a special rule
including the "as") as the following statements do not make any sense 
to me (same for some&every):

for $x as xs:string* in ...
for $x as xs:string+ in ...
for $x as xs:string? in ...
for $x as empty-sequence() in ...

The only thing that adds any semantic meaning is the empty-sequence()
statement which I would interpret as "give an error if this yields
something". But it's really cryptic and there are better ways to do
this.
Comment 1 Don Chamberlin 2005-09-29 08:45:48 UTC
Martin,
One of the most important principles of XQuery design is the orthogonality of 
the grammar. We define the basic parts of the grammar and use them consistently 
throughout the language--for example, the SequenceType production is used 
consistently wherever a type specification is needed.

As you have observed, a SequenceType is allowed to include an 
OccurrenceIndicator, which is not necessary when specifying a TypeDeclaration 
in a ForClause. However, if an OccurrenceIndicator is specified in this 
context, it is not harmful and its meaning is well-defined. For example, any 
variable binding that satisfies the SequenceType xs:integer also trivially 
satisfies the SequenceTypes xs:integer*, xs:integer+, and xs:integer?. I don't 
know any reason why a user would specify such a type in a ForClause, but I also 
don't know any reason to prohibit it. In general, we don't try to prevent users 
from writing expressions that are well-defined but useless.

On Sept. 28, 2005, the Query Working Group decided to close this comment 
without change to the XQuery specification. If you are satisfied with this 
resolution, please respond by closing this Bugzilla entry.

Thank you,
Don Chamberlin (on behalf of the Query Working Group) 
Comment 2 Martin Probst 2005-09-29 14:08:43 UTC
Well, that's fine with me, closing.