[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] replace


Subject: Re: [xsl] replace
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 12 Jun 2007 14:04:01 +0100

On 6/12/07, Charles Ohana <charles.ohana@xxxxxxxxxxxxxx> wrote:
I want to replace "a" by "b" inside "/root/@description" . I'm using XSLT
1.0 as I copied this code example from the web. it's not working with 2.0
either anyways. I'm not restricted to any version. All I need is to be able
to replace string .
Thank you

To replace single characters use translate() eg


translate(/root/@description, 'a', 'b')

which is in both XSLT 1.0 and 2.0

To replace more than one character you can use replace()

replace(/root/@description, 'aa', 'bb')

which is only in 2.0

To to do multiple character replacements in 1.0 you need the
lond-winded recursive named template approach, which what you've
copied from the web.

cheers
andrew


Current Thread
Keywords