Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Table of Contents

Search

  1. Preface
  2. Understanding Data Types and Field Properties
  3. Designing Processes
  4. Using and Displaying Data
  5. Designing Guides
  6. Designing Process Objects
  7. Designing Service Connectors
  8. Using App Connections
  9. System Services, Listeners and Connectors
  10. Designing Human Tasks

Design

Design

translate

translate

The translate function in XQuery is used to replace characters in a string based on a specified mapping from source characters to target characters. This function is useful for simple character substitutions and deletions within strings.

Syntax

fn:translate(arg, mapString, transString)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The input string in which character replacements are to be made. If this argument is an empty sequence (
()
), it is treated as an empty string.
mapString
Required
A string containing characters to be replaced. Each character in
mapString
is mapped to the corresponding character in
transString
.
transString
Required
A string containing replacement characters. Each character in
mapString
is replaced by the character at the corresponding position in
transString
. If
transString
is shorter than
mapString
, characters with no corresponding replacement are removed from the input.

Return Value

Returns a string where each character in the input
$src
is replaced according to the mappings defined by
$mapString
and
$transString
. Characters in
$src
that are not in
$mapString
remain unchanged. If replacements result in removal, those characters are removed.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:translate('1999/01/02', '/', '-')
1999-01-02
fn:translate('xml query', 'qlmx', 'QLMX')
XML Query
fn:translate('xml query', 'qlmx ', 'Q')
Query
fn:translate('xml query', 'qlmx ', '')
uery
fn:translate('xml query', 'abcd', 'ABCD')
xml query
fn:translate('', 'qlmx ', 'Q')
zero-length string
fn:translate((), 'qlmx ', 'Q')
zero-length string
fn:translate("hello world", "hod", "jrx")
"jellr wxrlr"
fn:translate("12345", "9", "0")
"12345"

0 COMMENTS

We’d like to hear from you!