Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Michael Kay" <mike@------------>
To:
Date: 12/1/2007 3:42:00 PM
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent