[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: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 01 Dec 2007 16:07:52 +0100
Re:  error:XSLT Stylesheet (possibly) contains a  recur
Hi Vaduvoiu

Your test is always false, unless the text itself is only a space. Change it to:

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

and you should be fine.

Note that in XSLT 2.0 you can do this with replace($text, ' [^ ]*', ''), which is a little bit shorter than your 14 lines, but you didn't mention whether you could use XSLT 2.0

If the strings get quite large, consider optimizing your template (if in XSLT 1.0, I mean) with substring-before.

Cheers,

-- Abel Braaksma




Vaduvoiu Tiberiu wrote:
Hi, i'm trying to do the following thing: I need to display a string until the last occurance of the space character.So if I would have "this is a news" i would need to display "this is a". I am using xslt1.0 and I tried doing the following:

<xsl:template name="extract">
<xsl:param name="text"/>
<xsl:variable name="length" select="string-length($text)"/>
<xsl:choose>
    <xsl:when test="substring($text,$length-1,$length)=' ' ">
        <xsl:value-of select="substring($text,1,$length-1)"/>
    </xsl:when>
<xsl:otherwise>
    <xsl:call-template name="extract">
        <xsl:with-param name="text" select="substring($text,1,$length-1)"/>
    </xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

basically I check if the last char of the string is space, display the text minus last char, otherwise, test again with text minus the last char. I get the error Error during XSLT transformation: XSLT Stylesheet (possibly) contains a recursion. I don't see why it would be interpreted as a infinit loop since the text keeps getting smaller.


____________________________________________________________________________________
Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.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.