W3C home > Mailing lists > Public > xsl-editors@w3.org > July to September 2000

Fw: replace-string() convenience function proposal

From: Steve Muench <smuench@us.oracle.com>
Date: Thu, 31 Aug 2000 12:26:11 -0700
Message-ID: <017c01c01381$520a4e90$fc652382@us.oracle.com>
To: <xsl-editors@w3.org>
For 2.0 requirements tracking in case we don't have
this on the list...
______________________________________________________________
Steve Muench, Lead XML Evangelist & Consulting Product Manager
BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
Author "Building Oracle XML Applications", O'Reilly
http://www.oreilly.com/catalog/orxmlapp/

----- Original Message ----- 
From: "Joe English" <jenglish@flightlab.com>
To: <xsl-list@mulberrytech.com>
Sent: Thursday, August 31, 2000 9:51 AM
Subject: Re: replace-string() convenience function proposal


| 
| Evan Lenz wrote:
| >
| > I would like a function such as replace-string() that would allow me to
| > replace one specified string with another specified string, within a
| > specified string.  For example, replace-string("Hello there", "Hello", "Hi")
| > would return "Hi there".  I use the following stylesheet (adapted from an
| > example in Kay's book) to do this for me now.
| > [ ... screenful of code snipped ]
| > The translate() function is great for one-to-one character replacements, but
| > as soon as you want to replace a character with, say, two characters
| 
| ... or even harder, replacing two or more characters with another string ...
| 
| > (as in
| > my example), you have to write a named template that recursively calls
| > itself, and pass all the parameters via <xsl:with-param/> each time you need
| > to call it, which, as you can see, can get quite ugly.
| >
| > I don't care what this function is called; maybe just replace() would be
| > better.
| >
| > Anyone want to second this motion (assuming it hasn't already been
| > proposed)?
| 
| 
| Seconded!
| 
| Tcl 8.2 and up has a [string map] function that does
| multiple simultaneous string-to-string substitutions
| in a single pass; Cost has a [substitution] command
| that does much the same thing.  This function is *absolutely
| indispensable* for converting XML/SGML to other markup
| notations.  It's also a heck of a lot easier to implement
| than a full regexp/regsub engine, and considerably easier
| to use too.  Something like this would be a very useful
| addition to XSLT.
| 
| 
| --Joe English
| 
|   jenglish@flightlab.com
| 
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 
Received on Thursday, 31 August 2000 15:31:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:50 GMT