W3C home > Mailing lists > Public > www-ql@w3.org > January to March 2004

RE: semantics of substring()

From: Howard Katz <howardk@fatdog.com>
Date: Fri, 12 Mar 2004 08:17:15 -0800
To: "Marcus Boerger" <mail@marcus-boerger.de>
Cc: <www-ql@w3.org>
Message-ID: <IKEOLCDFPBBPPAHGNKKOCEONEHAA.howardk@fatdog.com>

I'm presuming by Michael's prior example that substring( "12345", -1, 3) is
thus to be interpreted as the 3 characters starting from the -1'th position
in the string. Which gives "1".

Grappling with the concept of imaginary numbers in university helped
convince me that I didn't have a vocation in the hard sciences. Hopefully
the rather novel concept of imaginary character positions in strings won't
similarly drive me out of computing! :-)

Howard

> -----Original Message-----
> From: Marcus Boerger [mailto:mail@marcus-boerger.de]
> Sent: Friday, March 12, 2004 1:48 AM
> To: Howard Katz
> Cc: www-ql@w3.org
> Subject: Re: semantics of substring()
>
>
> Hello Howard,
>
> Friday, March 12, 2004, 2:28:09 AM, you wrote:
>
>
> > I don't understand one of the examples given for fn:substring()
> in the F and
> > O documentation [7.4.3]. The description of the function's
> behaviour says,
> > "If $startingLoc is zero or negative, the substring includes
> characters from
> > the beginning of the $sourceString." I take this to mean that
>
> >     substring( "12345", 0, 3 )
>
> > is equivalent to
>
> >     substring( "12345", 1, 3 )
>
> > which I understand evaluates to "123".
>
> > The example shown in the documentation however returns "12", and Saxon
> > echoes this. What am I misunderstanding?
>
> Wouldn't startlogic mean
>     substring("12345", -1, 3) = "123" or "12"
> the problem i have here is how to compute the length. starting with the
> nonexisting char at -1 or with the first existing one?
>
> --
> Best regards,
>  Marcus                            mailto:mail@marcus-boerger.de
>
Received on Friday, 12 March 2004 11:16:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 22 July 2006 00:10:19 GMT