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

RE: semantics of substring()

From: Michael Kay <mhk@mhk.me.uk>
Date: Fri, 12 Mar 2004 11:18:55 -0000
To: "'Howard Katz'" <howardk@fatdog.com>, <www-ql@w3.org>
Message-Id: <20040312111859.84B48A07A4@frink.w3.org>

Substring returns all characters whose position in the string is >= arg2 and
< arg2+arg3, so substring("123",0,3) returns characters in positions 0, 1,
and 2; there is no character in position 0, so you get "12".

Michael Kay

# -----Original Message-----
# From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of
# Howard Katz
# Sent: 12 March 2004 01:28
# To: www-ql@w3.org
# Subject: semantics of substring()
# 
# 
# 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?
# 
# TIA,
# Howard
Received on Friday, 12 March 2004 06:18:59 GMT

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