[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Re: What is $p in the definition of fn:subsequence ?


Subject: RE: [xsl] Re: What is $p in the definition of fn:subsequence ?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 5 Jul 2008 14:19:45 +0100

>   The spec doesn't specify the desired behavior if $length is <=  0.
> 
> Should the function return the empty sequence, a reversed 
> subsequence (if $length is < 0) or should an error be raised? 
> The same question goes for fn:substring().
> 

I think these questions are answered by the equivalences given in the
(corrected) spec.

subsequence((1 to 10), 5, -3)

is equivalent to

(1 to 10)[5 le position() and position() lt 5 - 3]

which is an empty sequence.

The same applies to substring().

(Note, in case you are wondering why it is this way: subsequence was
deliberately designed to imitate substring(), and substring() was designed
on the 1.0 design principle of "no runtime errors except as a last resort")

Michael Kay
http://www.saxonica.com/


Current Thread