W3C home > Mailing lists > Public > www-xpath-comments@w3.org > January to March 2002

RE: Erratum substring() function in XPath 1.0?

From: Kay, Michael <Michael.Kay@softwareag.com>
Date: Fri, 22 Mar 2002 18:04:04 +0100
Message-ID: <DFF2AC9E3583D511A21F0008C7E6210602679CF1@daemsg02.software-ag.de>
To: "'Svgdeveloper@aol.com'" <Svgdeveloper@aol.com>, "Kay, Michael" <Michael.Kay@softwareag.com>
Cc: www-xpath-comments@w3.org
The first sentence of the description of the substring() function states
that the third argument is the "length" of the string returned. However a
string "12" has, as I understand the term "length" (and as it is used in
relation to the string-length() function) a length of 2, not 3 as the third
argument would suggest. 
 
 
Yes; but the text goes on to make clear that the first sentence was an
informal description, and the formal specification is that it returns all
characters whose position p satisfies p >= arg2 and p < arg2 + arg3.

Perhaps I am being obtuse - I often am :) - but why is a value of 0, for
example, permitted for the second argument to the function?
 
I think it's a consequence of the design philosophy adopted for XSLT 1.0 and
XPath 1.0 that run-time errors are to be avoided at all costs. It's a
logical approach if you start by saying "what we should do if the user asks
for substring($x, 1, 5) and the string is only 4 characters long?" It makes
sense there to return the whole string. But if we accept a limit that's
beyond the right-hand end of the string, it becomes logical to accept a
limit that's beyond the left-hand end...
 
Anyway, for better or worse, that's the way it's specified, and it's
certainly not something we can change now.
 
Michael Kay
Received on Friday, 22 March 2002 12:04:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:05:54 GMT