W3C home > Mailing lists > Public > public-qt-comments@w3.org > January 2016

[Bug 29355] New: Modernize sequence filtering

From: <bugzilla@jessica.w3.org>
Date: Sun, 03 Jan 2016 21:22:49 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29355-523@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29355

            Bug ID: 29355
           Summary: Modernize sequence filtering
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Requirements for Future Versions
          Assignee: jim.melton@acm.org
          Reporter: benito@benibela.de
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

The syntax to get a subsequence in XQuery looks extremely dated.  
If you compare it too languages that became recently popular, you see that they
almost all support a syntax like sequence[from:to] or sequence[from:to:step] (
e.g. array[2:5] ) to get a subsequence like Python/Go/jq, or sequence[from..to]
like Perl/D/Ruby/Swift/Rust.  

A more modern sequence filtering would:

1. Allow negative numbers

$sequence[-1] to get the last value

$sequence[-2] to get the one before that ...

$sequence[$i] to get $sequence [last() + $i + 1] for $i < 0

2. Allow ranges

$sequence[ $list-of-numbers ]

as abbreviation for something like

$sequence[ position() = ($list-of-numbers ! (if (. > 0) then . else if (. < 0)
last() + . + 1 else xs:error("..") ) )  ]

Then you can at least do $sequence[2 to 4]


3. Add a by operator to skip the i-th elements. E.g. by 2 to get every second,
as in (("a", "b", "c", "d") by 2) returning ("a", "c")


With 2. and 3. you can write $sequence[2 to 10 by 3] to get the (2,5,8)-th
elements.

Except for 1. it should not break any existing script

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Sunday, 3 January 2016 21:22:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:57 UTC