[Bug 3305] Cardinality +/* on range variables

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3305

           Summary: Cardinality +/* on range variables
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery
        AssignedTo: chamberl@almaden.ibm.com
        ReportedBy: frans.englich@telia.com
         QAContact: public-qt-comments@w3.org


On queries such as:

for $i as xs:integer+ in (1, 2, 3) return $i
some/every $i as xs:integer+ in (1, 2, 3) satisfies $i

Saxon 8.7.1 SA raises the question of what the type declaration actually
applies on, by reporting XPTY0004, "Cardinality of range variable must be
exactly one."

What does the type declaration apply on?

One alternative is that Saxon is right, that the type declaration is applied on
each tuple binding individually. If this is the case, it makes no sense to
specify a cardinality other than exactly-one, in practice meaning that
specifying the type empty-sequence(), and cardinality +/* makes no sense and
should perhaps be statically forbidden.

The other alternative is that the type declaration applies on the initial
binding sequence as a whole, which must be the case of 'let' bindings. An
advantage of this alternative, is that the user can require a for/let/some
clause to be run at least once, by specifying a cardinality which disallows the
empty sequence.

The XQTS isn't of much guidance here. There are no tests specifying a
cardinality for 'for' tests(although tests involving empty-sequence exists),
and there are no type-declaration tests for quantifications in the latest
release.

I would with little doubt say that the latter is the correct way, but Saxon is
in that case stands out with having the exact opposite interpretation. Is an
editorial clarification appropriate? That at the end of the two
type-declaration paragraphs for 'for' and some/where is added "The type
declaration applies to the binding sequence as a whole, not on each item
individually."

One could argue that for and some/every should be consistent in this area, as
mentioned by Michael Kay in private mail.


Frans

Received on Wednesday, 31 May 2006 12:50:15 UTC