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

Infinite Loop when trying to use String-Replace

Subject: Infinite Loop when trying to use String-Replace
From: "Mataczynski, Jeff" <Jeff.Mataczynski@xxxxxxxxxxxxx>
Date: Wed, 31 Oct 2001 09:54:52 -0600
chargeuse a bois
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.  

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,'&#233;')">
		<xsl:call-template name="string-replace">
		<xsl:with-param name="string" select='$data'/>
		<xsl:with-param name="from">&#233;</xsl:with-param>
		<xsl:with-param name="to">00E9,e</xsl:with-param>
		</xsl:call-template>
	</xsl:if>
	<xsl:if test="not(contains($data,'&#233;'))">
	<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&#233;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&#233;brouissailleuse; outils de debusquage nommement cones de
d&#233;busquage, arches de debusquage, cables, poulies de renvoi
lat&#233;rales, colliers etrangleurs en polyester; outils de manutention
nomm&#233;ment devidoir d'entreposage de cable, plaque d'adaptation de
traction, colliers etrangleurs en polyester, scies d'elagage a main,
&#233;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


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.