Altova MapForce 2025 Basic Edition

Performs a character by character replacement. It looks in the value for characters contained in string1, and replaces each character with the one in the same position in the string2. When there are no corresponding characters in string2, the character is removed.

mf-func-translate

 

Languages

Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.

 

Parameters

Name

Description

value

The input string.

string1

Provides a list of search characters. The position of each character inside the string is important.

string2

Provides a list of replacement characters. The position of each replacement character must correspond to the one in string1.

 

Example

Let's suppose you want to convert the string [12,3] to (12.3). Namely, the square brackets must be replaced by round brackets, and any comma must be replaced by the dot character. To achieve this, you can call the translate function as follows:

mf-func-translate-example

In the mapping above, the first constant supplies the input string to be processed. The second and the third constant provide a list of characters as string1 and string2, respectively.

 

string1

[,]

string2

(.)

 

Notice that both string1 and string2 have the same number of characters. For each character in string1, the equivalent character at the same position from string2 will be used as a replacement. Consequently, the following replacements will take place:

 

Each [ will be replaced by a (

Each , will be replaced by a .

Each ] will be replaced by a )

 

The mapping output is as follows:

 

(12.3)

 

This function can also be used to strip certain characters selectively from a string. To achieve this, set the string1 parameter to the characters you want to remove, and string2 to an empty string. For example, the mapping below removes all digits from the string 38ab8a7a65xkh3.

mf-func-translate-example2

The mapping output is as follows:

 

abaaxkh

© 2018-2024 Altova GmbH