Thanks Martin for the feedback

I fixed the problem with the following query
> substring("12345", -42, 1 div 0)
in now returns "12345"
I'm glad to see that you are as confused as I am about the spec. They don't
treat infinity consistly also negative number seem to be take as 1,
sometiems 0.
BTW  substring("12345", 0, 3) returns "123" in the current implementation.
The probably mean add 3 + 0 = 2 (? strange math) and 0 is taken as 1
Anyway, it's a mess (the spec) as far as I can see.
Let me know if you spot any more bugs
Eddie




----- Original Message -----
From: <[EMAIL PROTECTED]>
To: Eddie Mc Greal <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, May 10, 2002 7:57 PM
Subject: Re: [Jaxen] substring function


>
> hey eddie,
>
> had a quick look at cvs and noted that infinity is not dealt with
> explicitly, though maybe it does what is expected anyhow.
> also:
>  if ( start < 0){
>       start = 0;
>  }else if (start + len > strlen){
>       return "";
>  }
>
> would fail for the following example from the spec:
> substring("12345", -42, 1 div 0) returns "12345"
>
> the else clause causes an exception for substrings exceeding the actual
> stringlength if the start was negative, ie when both conditions are true.
>
> furthermore i think it's probably incorrect to return "" when the
> stringlength is exceeded, my impression is it should return everything
> from the start position onwards, ie return str.substring(start);
>
> looking at the spec now i'm not even sure if rounding negative start
> values up to 0 is the right thing to do. seems that '0' is treated as 'one
> before the first':
> substring("12345", 0, 3) returns "12"
> would then '-1' mean two before the first character? now i'm confused..
>
>
> regards,
>
> /m
>
>
> On Fri, 10 May 2002, Eddie Mc Greal wrote:
>
> > I've checked in an updated version of the substring function and added
test
> > to the build
> > Previoulsy the substring function didn't handle invalid indices etc at
all -
> > an out of bounds eception was thrown
> > Now you get back an empty string along the lines of the spec.
> >
> > The W3 xpath spec def of substring is very confusing and I think
> > inconsistent if not wrong.
> > If you take a look at the example in the spec
> > http://www.w3.org/TR/xpath#section-String-Functions
> > you'll see what I mean. They don't treat 0, negative numbers and
infinity in
> > a consistent manner. (In the newer XPath 2.0 spec these are treated as
> > errors)
> >
> > Eddie
> >
> >
> >
> >
> > _______________________________________________________________
> >
> > Have big pipes? SourceForge.net is looking for download mirrors. We
supply
> > the hardware. You get the recognition. Email Us:
[EMAIL PROTECTED]
> > _______________________________________________
> > Jaxen-interest mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> >
>


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to