This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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)
Well, that's fine with me, closing.