O'Reilly logo

XSLT by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

translate() Function — Allows you to convert individual characters in a string from one value to another. In many languages, this function is powerful enough to convert characters from one case to another.

Synopsis

string translate(
               string
               string
               string
               )

Inputs

Three strings. The first is the original, untranslated string, and the second and third strings define the characters to be converted.

Output

The original string, translated as follows:

  • If a character in the original string appears in the second argument string, it is replaced with the corresponding character in the third argument string. In other words, if the character J appears in the original string and J appears as the fourth character in the second argument string, the J is replaced with the fourth character from the third argument string. (Don’t worry, we’ll have some examples to clear this up in just a minute.)

  • If a character in the original string appears in the second argument string and there is no corresponding character in the third argument string (the second argument string is longer than the third), then that character is deleted. In other words, if the character J appears in the original string, and J appears as the fourth character in the second argument string, and the third argument string is three characters long, the J is deleted.

  • If a character in the second argument string appears more than once, the first occurrence determines the replacement character.

  • If the third argument string is longer than the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required