[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: error:XSLT Stylesheet (possibly) contains a recur

Subject: RE: error:XSLT Stylesheet (possibly) contains a recursion.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 1 Dec 2007 15:41:05 -0000
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.