[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: error:XSLT Stylesheet (possibly) contains a recur
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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|