Re: fn:slice()

Which do you prefer?

Option A

A single (swiss-army-knife) slice() function as proposed yesterday

Option B

Three functions:

* fn:items-at($seq, xs:integer+) returning the items at the given positions

* fn:slice($seq, start?, step?,  (end | length)? ) accepting some combination of start, end, length, and step, each supplied as an integer

* fn:range($seq, (before | until)? (after | from)?) accepting predicates for the start and/or end of the selected range

This retains most of the useful combinations, but each of the functions is much simpler. (I've used an informal notation to indicate which combinations of parameters are allowed). Negative positions allowed for items-at, start, and end.

Option C

Two functions:

fn:slice($seq, $positions as integer+)

where $positions might be (3), (-1), (1 to 5) or ( 1 to 5 by 2).

fn:range($seq, (before | until)? (after | from)?) accepting predicates for the start and/or end of the selected range


Michael Kay
Saxonica

> On 4 Dec 2020, at 03:52, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
> 
> On Fri, Dec 4, 2020 at 8:04 AM Dimitre Novatchev <dnovatchev@gmail.com <mailto:dnovatchev@gmail.com>> wrote:
> While this function is obviously very powerful, its complexity affects the learning and confidence of use.
> 
> This leads to not-confident / hesitant / unhappy developers.
> 
> I agree to above mentioned concerns.
> 
> But +1 to introduction of fn:slice() function to XPath/XSLT. 
> 
>  
> 
> -- 
> Regards,
> Mukul Gandhi

Received on Friday, 4 December 2020 10:15:36 UTC