Subject: RE: Infinite Loop when trying to use String-Replace
From: "Ivan Pedruzzi" <ivan@xxxxxxxxxxxxxxx>
Date: Wed, 31 Oct 2001 22:12:06 -0500
|
Hi Jeff,
Stylus Studio detects possible infinite loop when the same template has
been invoked more then one time with the same parameters. This is a
warning and not an error, If you want you can turn it off
(Tools->Options->XSLT Editor->XSLT Settings).
The infinite loop detection avoid to hang the processor compare to other
applications that freeze forever.
Ivan Pedruzzi
eXcelon Corporation
http://www.stylusstudio.com
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Mataczynski, Jeff
> Sent: Wednesday, October 31, 2001 10:55 AM
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: Infinite Loop when trying to use String-Replace
>
>
> I'm trying to use a string-replace template in order to
> replace all occurences of the character "é" 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.
>
> Here's part of my stylesheet where I'm getting the error:
>
> <xsl:for-each select='goods.b/goods.blk'>
> <xsl:if test='label'>
> <Content><xsl:apply-templates
> select='label'/><xsl:text> </xsl:text></Content></xsl:if>
> <xsl:for-each select='goods/goods.detail'>
> <xsl:variable name="data" select='.'/>
> <xsl:if test="contains($data,'é')">
> <xsl:call-template name="string-replace">
> <xsl:with-param name="string" select='$data'/>
> <xsl:with-param name="from">é</xsl:with-param>
> <xsl:with-param name="to">00E9,e</xsl:with-param>
> </xsl:call-template>
> </xsl:if>
> <xsl:if test="not(contains($data,'é'))">
> <xsl:value-of select="$data"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:for-each>
>
> <!-- replace all occurences of the character(s) `from'
> by the string `to' in the string `string'.-->
>
> <xsl:template name="string-replace">
> <xsl:param name="string"/>
> <xsl:param name="from"/>
> <xsl:param name="to"/>
> <xsl:choose>
> <xsl:when test="contains($string,$from)">
> <xsl:value-of select="substring-before($string,$from)"/>
> <xsl:value-of select="$to"/>
> <xsl:value-of select="substring-after($string,$from)"/>
> <xsl:if
> test="contains(substring-after($string,$from),$from)">
> <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:if>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$string"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> My XML document looks like this:
>
> <goods.b afn="085">
> <label afn="085">Wares:</label>
> <goods.blk afn="085">
> <label afn="085">Translation:</label>
> <goods afn="085">
> <goods.detail afn="227">(1) Outils, nommement outils de
> sylviculture, d'elagage, d'abattage, de débardage,
> chargeuse a bois, chargeurs de grumes et treuils
> hydrauliques; outils nommement beches, plantoirs, cones,
> harnais utilises pour transporter tous types de semis,
> harnais de débrouissailleuse; outils de debusquage
> nommement cones de débusquage, arches de debusquage,
> cables, poulies de renvoi latérales, colliers
> etrangleurs en polyester; outils de manutention
> nommément devidoir d'entreposage de cable, plaque
> d'adaptation de traction, colliers etrangleurs en polyester,
> scies d'elagage a main, élagueurs a main, treuils a
> bras, poupees de cabestans et cabestans, remorques
> forestieres, accessoires pour vehicule tout-terrain,
> accessoires divers, nommement peinture biodegradable, ruban a
> mesurer, treuil manuel.</goods.detail>
> </goods>
> </goods.blk>
> </goods.b>
>
>
> Anyone have any ideas as to why I'm getting an infinite loop
> error? Any comments or suggestions would be greatly appreciated.
>
> Thanks,
> Jeff
>
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|