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 ...

Get XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.