Subject: [xsl] search and replace From: "Norma Yeazell" <Nyeazell@xxxxxxxxx> Date: Thu, 29 Apr 2004 09:29:29 -0400 |
I found this template on the list but am not sure how to implement it. I'm trying to replace ??degrees?? with ° in all xml tags. Is it possible and can someone explain how this template would/should work? I've tried a few variations and I keep getting an error that call-template not allowed in stylesheet message. Any help would be appreciated. Thanks <!-- sample how to use generic search-and-replace: --> <xsl:variable name="string" select="'string to be searched-and-replaced'"/> <xsl:variable name="find" select="'stringfragment-that-has-to-be-replaced'"/> <xsl:variable name="replace" select="'the-replacement-stringfragment'"/> <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> <!-- 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="''"/> <xsl:param name="replace" select="''"/> <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: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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] looping in xslt, Jeni Tennison | Thread | Re: [xsl] search and replace, Jeni Tennison |
Re: [xsl] Comparing two variables, David Carlisle | Date | Re: [xsl] Using XPath to retrieve n, Mukul Gandhi |
Month |