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]

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,'&#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


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