[Bug 28598] New: [FO31] (editorial) unclarity in description of negative starting position with fn:subsequence

https://www.w3.org/Bugs/Public/show_bug.cgi?id=28598

            Bug ID: 28598
           Summary: [FO31] (editorial) unclarity in description of
                    negative starting position with fn:subsequence
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Functions and Operators 3.1
          Assignee: mike@saxonica.com
          Reporter: abel.braaksma@xs4all.nl
        QA Contact: public-qt-comments@w3.org

We had a lengthy discussion this morning about this seemingly trivial point. We
concluded that the spec is correct, but that it was open for some ambiguity,
hence this bug report / editorial enhancement request.

The FO30 and FO31 spec says, about a negative starting position:

   * If $startingLoc is zero or negative, the subsequence includes items from 
     the beginning of the $sourceSeq.

This is easily misread, as in our case, that if $startingLoc is zero or
negative, it is taken as 1.

But after looking at existing behavior of implementations and expected test
outcomes, the actual sequence slice taken is from position 1 to $length +
$startingPos (in other words, from the start to the difference between these
two numbers).

If $length = 1, $start = 0, the first item is returned
If $length = 1, $start = -1, the empty seq is returned
If $length = 5, $start = -3, the first two items are returned

After looking again to the written out function, it is formally working that
way. But we found the text vague:

- there are not always items from returned from the beginning of the $source
- the number of items is not equal to the $length argument

I'm not sure if, whether, or how this can/sould be improved, but I am rooting
for something along those lines: 

   * If $startingLoc is zero or negative, the subsequence includes items from
     the start of the sequence to position = $length + $startingPos, or the 
     empty sequence if the result is zero or negative.

In addition to this, it might also proof helpful or add to clarity to have a
statement like: if $length is zero or negative, the empty sequence is returned.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 4 May 2015 07:31:08 UTC