This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Infinite Loop when trying to use String-Replace


dont use stylus

cheers, jim fuller

----- Original Message -----
From: "Mataczynski, Jeff" <Jeff.Mataczynski@westgroup.com>
To: "'Jeni Tennison'" <jeni@jenitennison.com>
Cc: <XSL-List@lists.mulberrytech.com>
Sent: Wednesday, October 31, 2001 7:08 PM
Subject: RE: [xsl] Infinite Loop when trying to use String-Replace


> I tried using your template, but Stylus is still detecting an infinite
loop.
> Any other suggestions?
>
> Jeff
>
> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@jenitennison.com]
> Sent: Wednesday, October 31, 2001 12:53 PM
> To: Mataczynski, Jeff
> Cc: 'XSL-List@lists.mulberrytech.com'
> Subject: Re: [xsl] Infinite Loop when trying to use String-Replace
>
>
> Hi Jeff,
>
> > I'm trying to use a string-replace template in order to replace all
> > occurences of the character "&#233;" in a string. However, when I
> > try to run it in Stylus, I keep getting an error that the XSL
> > processor has detected an infinite loop. I cannot determine why I'm
> > getting this.
>
> There isn't an infinite loop with the source that you sent, but
> perhaps Stylus is really clever and is detecting one anyway because
> contains($string, $from) returns true if $from is an empty string. The
> template is a bit strange anyway, because it always gives the value
> after the $from in the $string as well as than stepping on
> recursively. Try the following:
>
> <xsl:template name="string-replace">
>   <xsl:param name="string"/>
>   <xsl:param name="from"/>
>   <xsl:param name="to"/>
>   <xsl:choose>
>     <xsl:when test="string($from) and contains($string, $from)">
>       <xsl:value-of select="substring-before($string, $from)" />
>       <xsl:value-of select="$to"/>
>       <xsl:call-template name="string-replace">
>         <xsl:with-param name="string"
>                         select="substring-after($string, $from)" />
>         <xsl:with-param name="from" select="$from"/>
>         <xsl:with-param name="to" select="$to"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="$string"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
> I hope that helps,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]