Name
translate( ) — returns the src
string, with characters replaced from a list
Synopsis
Defined in: XPath 1.0 |
Parameters: string src (required), string removechars (required), string replacechars (required) |
Return type: string |
Characters from the removechars
string replaced with
characters from the corresponding position in the
replacechars
string. The
removechars
string may be longer than the
replacechars
string, in which case the additional
characters are simply removed from the src
string.
Note
In many languages, translate( )
can be used to
perform case conversion. For example, to convert English to
uppercase, the call you need would be
translate(
src
,
"abcdefghijklmnopqrstuvwxyz
“,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ
“).
A future edition of XPath may include specific functions for case conversion.
The first example returns “hello world!”, and the second example returns “hello world” (note that the exclamation point is gone):
translate("Hello World!", "HW", "hw") translate("Hello World!", "HW!", "hw")
Get XForms Essentials 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.