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

RE: Infinite Recursion Looking for Whitespace.

Subject: RE: Infinite Recursion Looking for Whitespace.
From: "HEATH ALLISON" <HEATH.ALLISON@xxxxxxxxxxxxxxx>
Date: Mon, 27 Jan 2003 12:21:13 -0600
heath allison
Andy,

I've amended the code below to show a "failsafe" I added to the if statement:

<xsl:template name="looper">
	<xsl:param name="leftStringLength"/>
	<xsl:param name="leftStringValue"/>
		
		<xsl:if test="substring($leftStringValue,number($leftStringLength),'-1') != 't' and $leftStringLength >0 ">

		String Length: <xsl:value-of select="$leftStringLength" /> <BR/>
		String Value: <xsl:value-of select="$leftStringValue" /> <BR/>
		String End: <xsl:value-of select="substring($leftStringValue,number($leftStringLength),'1')" /><BR/>
		
		<!-- recursive call -->
			<xsl:call-template name="looper">
				<xsl:with-param name="leftStringLength" select="$leftStringLength - 1"/>
				<xsl:with-param name="leftStringValue" select="substring($leftStringValue,'1',number($leftStringLength)-'1')" />
			</xsl:call-template> 
		</xsl:if>
	
</xsl:template>

I've put some debug code in there to write out the values of both the stringlength and the stringvalue. It's rifling through one character at a time, but it's ignoring the condition to test the value of the character... it stops on the "and" condition of >0 but not on the != condition of whatever character I supply...

heath deforrest allison
"Arrowed!"




-----Original Message-----
From: Andy J. Cupp [mailto:acupp@xxxxxxxxxxxxxxx]
Sent: Monday, January 27, 2003 11:51 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Infinite Recursion Looking for Whitespace.


Hi Allison.  From your remarks, it seems you may have worked on this already, but I think you need an additional test to end the recursion.  Currently, if the template never encounters a blank space, it will just keep looping, sending nothing as the $leftStringValue parameter and -1,-2,-3,... as the $leftStringLeft parameter.  Maybe if you just have a test in the form of <xsl:if test="$leftStringValue">, that would end your recursion when the string has been examined.

-----Original Message-----
From: HEATH ALLISON [mailto:HEATH.ALLISON@xxxxxxxxxxxxxxx]
Sent: Monday, January 27, 2003 10:57 AM
To: XSL List
Subject:  Infinite Recursion Looking for Whitespace.


Hello again, I'm still trying to fix my line-break problem. I'm trying to get my recursion loop to rifle through the value of $leftStringValue from the end to the start, but stop when it encounters the first blank space. The xsl:if test works if I set it to the value of $stringLength with a test of "> 0". But the second I change it to look for a space at the last position in a substring of $stringValue it goes infinite and overflows the stack. Any suggestions?

<xsl:template name="loop">
	<xsl:param name="leftStringLength"/>
	<xsl:param name="leftStringValue"/>
		
		<xsl:if test="(normalize-space(substring($leftStringValue,number($leftStringLength),'1'))) != ' ' ">

		String Length: <xsl:value-of select="$leftStringLength" /> <BR/>
		String Value: <xsl:value-of select="$leftStringValue" /> <BR/>
		String End: <xsl:value-of select="substring($leftStringValue,number($leftStringLength),'1')" /><BR/>
		
		<!-- recursive call -->
			<xsl:call-template name="loop">
				<xsl:with-param name="leftStringLength" select="$leftStringLength - 1"/>
				<xsl:with-param name="leftStringValue" select="substring($leftStringValue,'1',number($leftStringLength)-'1')" />
			</xsl:call-template> 
		</xsl:if>
	
</xsl:template>


heath deforrest allison
"Arrowed!"




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.