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

RE: Infinite Loop when trying to use String-Replace

Subject: RE: Infinite Loop when trying to use String-Replace
From: Christopher_Dant@xxxxxxxxxxxxxx
Date: Wed, 31 Oct 2001 14:48:52 -0500
director string replace
I 'd suggest that you try Saxon instead either from the command line or
from with Stylus. You can use Saxon in Stylus:
- Tools > Options > External XSLT
- In "Default custom processor command line put something like:
  c:\xsltproc\oraxml\saxon.exe %1 %2 %3

You can download the compiled version of Instant Saxon (for Windows
platform) from its SourceForge project page at
http://sourceforge.net/projects/saxon.

Note that Stylus just won't do everything you'll need it to, though it's
getting better. One last thought - I've found it helpful to have several
XSLT processors on hand for debugging and experimentation. More than once I
gained a crucial insight from an a processor that I wasn't using regularly.

HTH,
Chris

Christopher Dant
Technology Director
Jack Morton Worldwide
Christopher_Dant@xxxxxxxxxxxxxx
Voice (973) 581-1700 x141
Fax (973) 581-1701
-- NEW PHONE NUMBERS --


                                                                                                       
                    "Mataczynski, Jeff"                                                                
                    <Jeff.Mataczynski@westgroup       To:     "'Jeni Tennison'"                        
                    .com>                              <jeni@xxxxxxxxxxxxxxxx>                         
                    Sent by:                          cc:     "'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'"      
                    owner-xsl-list@xxxxxxxxxxxx        <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>               
                    rytech.com                        Subject:     RE:  Infinite Loop when trying 
                                                       to use String-Replace                           
                                                                                                       
                    10/31/2001 02:08 PM                                                                
                    Please respond to xsl-list                                                         
                                                                                                       
                                                                                                       




I tried using your template, but Stylus is still detecting an infinite
loop.
Any other suggestions?

Jeff

-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
Sent: Wednesday, October 31, 2001 12:53 PM
To: Mataczynski, Jeff
Cc: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
Subject: Re:  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


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.