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

multiple search and replace

Subject: multiple search and replace
From: "Norma Yeazell" <Nyeazell@xxxxxxxxx>
Date: Fri, 30 Apr 2004 10:37:56 -0400
xsl search and replace
The following snip works fine but can anyone tell me whether there is a
better more efficient way to replace more than one item.

<xsl:template match="text()">
  <xsl:call-template name="_replace_string">
    <xsl:with-param name="string" select="." />
    <xsl:with-param name="find" select="'?degrees?'" />
    <xsl:with-param name="replace" select="'&#xB0;'" />
    <xsl:with-param name="find2" select="'Nm'" />
    <xsl:with-param name="replace2" select="'N&#xb7;m'" />
  </xsl:call-template>
</xsl:template>

<!-- template to look for all instances of string $find and
replace that with string $replace -->
<xsl:template name="_replace_string">
<xsl:param name="string" select="''"/>
<xsl:param name="find" select="'find'"/>
<xsl:param name="replace" select="'replace'"/>
<xsl:param name="find2" select="'find2'"/>
<xsl:param name="replace2" select="'replace2'"/>
<xsl:choose>
<xsl:when test="contains($string,$find)">
<xsl:value-of
select="concat(substring-before($string,$find),$replace)"/>
<xsl:call-template name="_replace_string">
<xsl:with-param name="string" select="substring-after($string,$find)"/>
<xsl:with-param name="find" select="$find"/>
<xsl:with-param name="replace" select="$replace"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($string,$find2)">
<xsl:value-of
select="concat(substring-before($string,$find2),$replace2)"/>
<xsl:call-template name="_replace_string">
<xsl:with-param name="string" select="substring-after($string,$find2)"/>
<xsl:with-param name="find2" select="$find2"/>
<xsl:with-param name="replace2" select="$replace2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>



Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.

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.