You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stuart Roebuck <sr...@adolos.com> on 2000/05/10 11:54:55 UTC

Re: [Q] 1.7.3 - Fault with "substring" function = Math.round() fault

Tom,

Begin forwarded message:

> On Tue, 9 May 2000, Stuart Roebuck wrote:
>
> > I'm getting a StringIndexOutOfBoundsException trying to use the XPath   
> > substring(string, start, length) function.  I've tried a simple:
> >
> > <xsl:variable name="test_variable" select="substring("1234",1,2)" />
> >
> > And this returns the same stack trace (see below).
> > > java.lang.StringIndexOutOfBoundsException: String index out of range: 
>
> substring() works fine for me; i couldn't reproduce your specific error, 
> although you've made a mistake in the quoting - you can't nest double
> quotes, so your example should be:
>
> <xsl:variable name="test_variable" select="substring('1234',1,2)" />
>
> i don't know if that's any help.

Thanks for your reply.  I introduced the quoting mistake when I was  
writing the email - unfortunately that isn't the actual problem.  It looks  
like the problem is a fault with the Math.round() function on the  
implementation of Java 1.2.2 I'm working on.

I've downloaded the Xalan source, so I'm just going to try patching in a  
call to Math.trunc() instead and see if that solves the problem.

Cheers,

Stuart.