Here's a sample template that lets you have the String.Replace() functionality in XSLT 1.0. The template "string-replace-all" takes 3 parameters and recursively processes the input text string.
- text : main string
- replace : the string fragment to be replaced
- by : the replacement string

Here's how it is called:

The resulting value of $myVar after {ReplaceMe} is replaced is "This is a sample text : String.Replace() in XSLT and String.Replace() in XSLT"
For those who are not familiar with XSLT syntax and here's the C# equivalent. An excellent material for the thedailywtf! :)

(Note: I'm not so sure, but I think in XSL 2.0 there is already a built-in replace function on strings)
Print | posted on Tuesday, April 01, 2008 8:36 PM