xsl-list
[Top] [All Lists]

RE: [xsl] error:XSLT Stylesheet (possibly) contains a recursion.

2007-12-01 08:41:36

It's a pretty ropey error message - your stylesheet clearly does contain a
recursion and there's nothing wrong with that.

    <xsl:when test="substring($text,$length-1,$length)=' ' ">

I'll assume you either wrote "$length -1" with a space, or that you've got a
buggy XSLT processor that treated the "-" as a minus sign rather than a
hyphen.

If $text is "abcde", then this selects "de", which I don't think is what you
intended. Perhaps you're confusing it with Java's substring method.

basically I check if the last char of the string is space, 

No, that's not what your code is doing. Check the spec.

Your recursive call does this:

<xsl:with-param name="text" select="substring($text,1,$length-1)"/>

again, I assume you must really have written "$length -1" otherwise this
wouldn't compile at all. If $length is greater than one, this will always
select a shorter string that you started with, which suggests that the
recursion ought to terminate. Unfortunately, though, when the string reaches
length zero, your test test="substring($text,$length-1,$length)=' ' ">
returns false, so you recurse infinitely processing a zero-length string.
Even if you correct your xsl:when to test properly for a trailing space,
it's obvious that your template will never terminate if passed a string that
is zero-length or that contains no spaces.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>