List of Experlogix Template Builder functions

The Experlogix Template Builder offers a large number of functions that you can use in your expressions. Use the expression tables below to power your Templates with additional functionality via expressions.

Regular expressions

Some of the functions you can use allow you to use regular expressions. To learn more about regular expressions, refer to Java Tutorials.

Extended characters

Some of the functions you can use allow you to use extended characters. To learn more about extended characters, refer to Control character.

Basic Functions

Characters

Description

\n

Newline

\r

Carriage return

\t

Tab

\\

Backslash

\x##

Hexadecimal value (between 00 and FF)

\u####

Extended hexadecimal value meant for Unicode characters (between 0000 and FFFF)

\d###

Decimal value (between 000 and 255)

Mathematical functions

Elementary arithmetic

Function name

Description

Syntax

Example

Copy
add

Returns the sum of c and b (c + b).

add(c, b)

add('1.2', '2.3') = 3.5

add('1.2', 2.3) = 3.5

add(1.2, 2.3) = 3.5

Copy
uadd

Returns the sum of c and 1 (c + 1).

uadd(c)

uadd(10) = 11

Copy
sub

Returns the result of subtracting b from c (c - b).

sub(c, b)

sub(9,3) = 6

sub(3,9) = -6

Copy
div

Returns the result of dividing c by b (c / b).

div(c, b)

div(9,2) = 4.5

div(-9,2) = -4.5

div(2,4) = 0.5

Copy
mod

Returns the remainder of the division of c and b.

mod(c, b)

mod(9,2) = 1

mod(9,3) = 0

mod(8,3) = 2

mod(-9,-2) = -1

Copy
mult

Returns the multiplication of c with b (c × b).

mult(c, b)

mult(2,6.5) = 13

mult(-2,8) = -16

Copy
sum

Returns the sum of all arguments (a + b + c + d...).

sum(a, b, c, d...)

sum(1,6.5,2) = 9.5

sum(1,0,0,0,6) = 7

Copy
prod

Returns the product of all arguments (a x b x c x d...).

prod(a, b, c, d...)

prod(2,3,4) = 24

prod(-2,1,-3.5,2) = 14

Basic

Function Name

Description

Synta

Example

Copy
md

Returns a new random number between 0.0 and 1.0. Seed is the number used to initialize a pseudo-random number generator. The seed is not required.

rnd(seed)

rnd(25) = 0.645

Copy
abs

Returns the absolute value of c (|c|).

abs(c)

abs(123) = 123

abs(-123) = 123

Copy
max

Returns the largest number of c and b.

max(c, b)

max(5,2) = 5

max(-3,7) = 7

max(-3,-5) = -3

Copy
min

Returns the smallest number of c and b.

min(c,b)

min(5,2) = 2

min(-3,7) = -3

min(-3,-5) = -5

Copy
negate

Returns c multiplied with -1.

negate(c)

negate(63) = -63

negate(-63) = 63

Copy
sign

Returns -1 if c is negative, 1 if c is positive, and 0 if c is 0.

sign(c)

sign(0) = 0

sign(-4) = -1

sign(7) = 1

Copy
val

Converts c to a floating point value.

val(c)

val(1.2) = 1.2

Power

Function Name

Description

Syntax

Example

Copy
sqrt

Returns the square root of c.

sqrt(c)

sqrt(121) = 11

sqrt(499849) = 707

Copy
sqr

Returns the square of c (c²).

sqr(c)

sqr(11) = 121

sqr(707) = 499849

Copy
exp

Returns e raised to the power c.

exp(c)

exp(2) = 7.389

Copy
pow

Returns c raised to the power b (c ^ b).

pow(c, b)

pow(10,3) = 1000

pow(2,8) = 256

pow(3,3) = 27

Logarithms

Function Name

Description

Syntax

Example

Copy
ln

Returns the natural logarithm of c (base e).

ln(c)

ln(10) = 2.303

Copy
log

Returns the logarithm of c in base 10.

log(c)

log(1000) = 3

log(100) = 2

Copy
log2

Returns the logarithm of c in base 2.

log(c)

log2(1024) = 10

log2(256) = 8

Copy
logn

Returns the logarithm of c in base n.

logn(c, n)

logn(343,7) = 3

logn(64,4) = 3

logn(100,10) = 2

Rounding

Function Name

Description

Syntax

Example

Copy
ceil

Returns the smallest integer higher than or equal to c (rounding up).

ceil(c)

ceil(1.0) = 1

ceil(1.1) = 2

ceil(1.8) = 2

ceil(-1.0) = -1

ceil(-1.1) = -1

Copy
floor

Returns the largest integer lower than or equal to c (rounding down).

floor(c)

floor(1.0) = 1

floor(1.1) = 1

floor(2.5) = 2

floor(-1.0) = -1

floor(-1.3) = -2

Copy
trunc

Returns c without the decimal part.

trunc(c)

trunc(1.0) = 1

trunc(1.6) = 1

trunc(2.5) = 2

trunc(-3.6) = -3

Copy
round

Returns c rounded to the nearest integer. 

round(c)

round(1.0) = 1

round(1.2) = 1

round(1.5) = 1

round(1.7) = 2

Copy
roundDecimal

Returns c rounded to a number of decimal places (b).

roundDecimal(c,b)

round(2.12355,3) = 2.124

round(2.12555,3) = 2.126

round(2.12555,2) = 2.13

round(2.12555,1) = 2.1

Trigonometrical

Function Name

Description

Syntax

Example

Copy
sin

Returns the sine of c (c in degrees).

sin(c)

sin(0) = 0

sin(30) = 0.5

sin(45) = 0.707

sin(90) = 1

Copy
cos

Returns the cosine of c (c in degrees).

cos(c)

 

cos(0) = 1

cos(45) = 0.707

cos(60) = 0.5

cos(90) = 0

Copy
tan

Returns the tangent of c. (c in degrees).

tan(c)

tan(0) = 0

tan(45) = 1

tan(60) = 1.732

Counting

Function Name

Description

Syntax

Example

Copy
avg

Returns the average of all the arguments. Blank values are not included.

avg(a,b,c...)

 

Copy
avga

Returns the average of all the arguments. Blank values are included and considered to be zero.

avga(a,b,c...)

 

Copy
median

Returns the median of all the arguments. Blank values are not included.

median(a,b,c...)

median(1,5,7) = 5

median(3,6,18) = 6

median(3,6,8,11) = 7

Copy
mediana

Returns the median of all the arguments except x. Blank values get the value x.

mediana(x,a,b,c...)

 

Copy
mode

Returns the number that most often appears in the arguments. Blank values are not included.

mode(a,b,c...)

mode(1,2,2,3) = 2

mode(1,2,2,3,3) = no mode

mode(1,2,2,3,3,3) = 3

Copy
modea

Returns the number that most often appears in the arguments except x. Blank values get the value x. 

modea(x,a,b,c...)

 

Copy
count

Counts the number of values. Blank values are not included.

count(a,b,c...)

 

Copy
counta

Counts the number of values. Blank values are included.

counta(a,b,c...)

 

Copy
countb

Counts the number of blank values.

countb(a,b,c...)

 

Copy
countDistinctValues

Counts the number of distinct values. Blank values are not included.

countDistinctValues(a,b,c...)

countDistinctValues(a,a,a,b,b) = 2

countDistinctValues(a,b,c,c,c,c) = 3

Copy
countDistinctValuesA

Counts the number of distinct values. Blank values are included.

countDistinctValues(a,b,c...)

 

Text functions

Basic

Function Name

Description

Syntax

Example

str

Converts c to a string.

str(c)

str(1.2) = 1.2

strlen

Returns the length of c.

strlen(c)

strlen('Hello world!') = 12

strlen('Xpertdoc') = 8

concat

Returns the string that results from concatenating c and b. You can use more than two arguments.

concat(c, b)

concat('Hello ', 'world') = 'Hello world'

concat('Hi ','there ','everyone') = 'Hi there everyone'

substr

Returns the sub-string of s starting from c with length b.

substr(s, c, b)

substr('Hello World!', 1, 4) = 'ello'

substr('Hello World!', 3, 2) = 'lo'

substr('Hello World!', 3, -2) = 'el'

substr('Hello World!', 100, -4) = 'rld!'

chr

Returns the nth character of c.

chr(c, n)

chr('Xpertdoc', 2) = 'p'

chr('Xpertdoc', 150) = ''

Trim

Function Name

Description

Syntax

Example

trim

Removes all leading and trailing whitespaces from c.

trim(c)

trim('       some    text      ') = 'some    text'

rtrim

Removes all trailing whitespaces from c.

rtrim(c)

rtrim('          some    text      ') = '          some    text'

ltrim

Removes all leading whitespaces from c.

ltrim(c)

ltrim('          some    text      ') = 'some    text      '

Case

Function Name

Description

Syntax

Example

toLower / lowercase

Returns c with all characters in lowercase.

  • toLower(c)

  • lowercase(c)

toLower('Xpertdoc') = 'xpertdoc'

lowercase('Xpertdoc') = 'xpertdoc' 

toUpper / uppercase

Returns c with all characters in uppercase.

  • toUpper(c)

  • uppercase(c)

toUpper('Xpertdoc') = 'XPERTDOC'

uppercase('Xpertdoc') = 'XPERTDOC'

capitalizeEachWord

Returns c where each word has a capital first letter.

capitalizeEachWord(c)

capitalizeEachWord('this is very good.') = 'This Is Very Good.'

sentenceCase

Returns c where each sentence is capitalized.

sentenceCase(c)

sentenceCase('hi there. we are going to start.') = 'Hi there. We are going to start.'

toggleCase

Returns c where each letter's case is inverted.

toggleCase(c)

toggleCase('This is a strange function according to Dr. Strangefunction.') = 'tHIS IS A STRANGE FUNCTION ACCORDING TO dR. sTRANGEFUNCTION.'

Replace

Function Name

Description

Syntax

Example

replaceText

Returns a string where each occurrence of d in c has been replaced with e. Case is ignored.

replaceText(c, d, e)

replaceText('The quick brown fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog'

replaceText('The quick brown fox jumps over the lazy dog', 'BROWN', 'ORANGE') = 'The quick ORANGE fox jumps over the lazy dog'

replaceText('The quick BROWN fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog'

replaceText('The quick brown fox jumps over the lazy dog', 'brown', '') = 'The quick  fox jumps over the lazy dog'

replaceTextC

Returns a string where each occurrence of d in c has been replaced with e. Case-sensitive.

replaceTextC(c, d, e)

replaceTextC('The quick brown fox jumps over the lazy dog', 'brown', 'orange') = 'The quick orange fox jumps over the lazy dog'

replaceTextC('The quick brown fox jumps over the lazy dog', 'BROWN', 'ORANGE') = 'The quick brown fox jumps over the lazy dog'

replaceTextC('The quick BROWN fox jumps over the lazy dog', 'brown', 'orange') = 'The quick BROWN fox jumps over the lazy dog'

replaceTextC('The quick brown fox jumps over the lazy dog', 'brown', '') = 'The quick  fox jumps over the lazy dog'

replaceExtended

Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be texts with extended characters. Case is ignored.

replaceExtended(c, d, e)

replaceExtended('"??"', '\u0100', 'Latin capital letter A with macron') = '"Latin capital letter A with macron"'

replaceExtendedC

Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be texts with extended characters. Case-sensitive.

replaceExtendedC(c, d, e)

replaceExtendedC('"??"', '\u0100', 'Latin capital letter A with macron') = '"Latin capital letter A with macron"'

replaceRegEx

Returns a string where each occurrence of d in c has been replaced with e. d and e are considered to be regular expressions.

replaceRegEx(c, d, e)

replaceRegEx('The quick brown fox jumps over the lazy dog', '(dog|fox)', '\[animal\]$1\[animal\]') = 'The quick brown [animal]fox[animal] jumps over the lazy [animal]dog[animal]'

Split

If you use any of the split functions, you need to configure it using the following steps:

1. Create a pseudo-field where you use the split function on a field.
2. Loop over the pseudo-field in your template.
3. In the loop, map the pseudo-field again. If your field is called Address1, this is what you'll end up with:

If you do not loop, you'll only get the first item instead of all the items.

Function Name

Description

Example

split

Splits a field into separate parts, which can be stored as an array in a pseudo-field. These can then be accessed by mapping the pseudo-field split(text, separator, isRegex, removeEmpty, trimParts).

Split Type

Description

text

The text to be split into pieces (text).

separator

The value to split on (text).

isRegex

Whether separator is a regular expression or not (1 = true, 0 = false).

removeEmpty

Whether to remove empty pieces from the result (1 = true, 0 = false).

trimParts

Whether to trim the pieces (1 = true, 0 = false).

  • split on lines split(${./Content}, '\\\\r?\\\\n', 1, 1, 1)—Splits the value of element <Content> into pieces separated by the regular expression \r?\n. Empty parts are removed and the separate parts are trimmed. The reason that you need to place all the backslashes here is that the regular expression is translated two times before it is fed to the regular expression matcher. The expression is translated to a java-string before it is evaluated; \\\\r -> \\r -> \r.

  • split on ',' or ';' split(${./Content}, '[,]|[;]', 1, 0, 0) Splits the value of element <Content> into pieces separated by the regular expression [,]|[;]. This means either a comma or a semi-colon. Empty parts are kept and the separate parts are not trimmed.

  • split on space split(${./Content}, ' ', 0, 0, 0)—Splits the value of element <Content> into pieces separated by one space. Empty parts are kept and the separate parts are not trimmed.

splitLines

Splits a field into separate parts, splitting on newlines splitLines(text). This function is equivalent to split(text, '\\r?\\n', 1, 0, 0) and will split text into pieces separated by a newline.

 

splitWords

Splits a field into separate parts, splitting on whitespaces splitWords(text). This function is equivalent to split(text, '\\\\s+', 1, 1, 1) and will split text into pieces separated by whitespaces.

 

Format

Function Name

Description

Syntax

Example

formatNumber

Output a number in a given pattern. For more information, refer to Number patterns.

formatNumber(number,pattern)

formatNumber(500,'0.00') = 500.00

formatNumber(200,'##.##') = 200

formatNumberR

Output a number in a given pattern, using a certain locale. For more information, see Number patterns and List of supported locales.

formatNumber(number,pattern,locale)

formatNumberR(500,'¤0.00','en_us') = $500.00

formatNumberR(500,'¤0.00','nl_be') = €500,00

Date & time functions

For details on Date & time functions, please refer to the following pages

Logical functions

Logic

Function Name

Description

Syntax

Example

if

Returns d if c equates to true, e if c equates to false.

if(c, d, e)

if(1, yes, no) = yes

if(0, yes, no) = no

if(2, yes, no) = yes

if(-1, yes, no) = yes

and

Returns the logical AND of c and d.

and(c, d)

and(1, 1) = 1

and(1, 0) = 0

and(0, 1) = 0

and(0, 0) = 0

or

Returns the logical OR of c and d.

or(c, d)

or(1, 1) = 1

or(1, 0) = 1

or(0, 1) = 1

or(0, 0) = 0

not

Returns 1 if c is 0, 0 otherwise.

not(c)

not(0) = 1

not(1) = 0

not(2) = 0

not(-1) = 0

Comparison

Function Name

Description

Syntax

Example

eq

Returns 1 if c is equal to d, 0 otherwise. When used with text, the values are trimmed (trailing and leading whitespaces are removed), and case is ignored.

eq(c, d)

eq(2, 2) = 1

eq(2, 5) = 0

eq(2.0, 2) = 0

eq('   AbC  ','abc') = 1

neq

Returns 1 if c is not equal to d, 0 otherwise. When used with text, the values are trimmed (trailing and leading whitespaces are removed), and case is ignored.

neq(c, d)

eq(2, 2) = 0

eq(2, 5) = 1

eq(2.0, 2) = 1

eq('   AbC  ','abc') = 0

neq

Extensions of eq and neq. The eq and neq functions can be extended for use with text:

Function Name

Description

eqc

The same as eq, but case-sensitive.

eqt

The same as eq, but the values are not trimmed.

eqct

The same as eq, but case-sensitive and the values are not trimmed.

neqc

The same as neq, but case-sensitive.

neqt

The same as neq, but the values are not trimmed.

neqct

The same as neq, but case-sensitive and the values are not trimmed.

 

 

gt

Returns 1 if c is bigger than d, 0 otherwise.

gt(c, d)

gt(2, 1) = 1

gt(2, 5) = 0

gt(2, 2) = 0

geq

Returns 1 if c is bigger than or equal to d, 0 otherwise.

geq(c, d)

geq(2, 1) = 1

geq(2, 5) = 0

geq(2, 2) = 1

lt

Returns 1 if c is lower than d, 0 otherwise.

lt(c, d)

lt(2, 1) = 0

lt(2, 5) = 1

lt(2, 2) = 0

leq

Returns 1 if c is lower than or equal to d, 0 otherwise.

leq(c, d)

leq(2, 1) = 0

leq(2, 5) = 1

leq(2, 2) = 1

hasBlanks

Returns 1 when at least one of the arguments is blank.

hasBlanks(a,b,c...)

 

isNull

Returns 1 when c is unspecified (null).

isNull(c)

 

isNullOrBlank

Returns 1 when c is unspecified (null) or blank (empty or only whitespaces).

isNullOrBlank(c)

 

Check text

Function Name

Description

Syntax

Example

contains

Returns 1 if c contains s, 0 if it doesn't. Case is ignored.

contains(c, s)

contains('Xpertdoc', 'Xp') = 1

contains('Xpertdoc', 'xP') = 1

contains('Xpertdoc', 'Xu') = 0

contains('Xpertdoc', 'u') = 0

containsc

Returns 1 if c contains s, 0 if it doesn't. Case-sensitive.

containsc(c, s)

containsc('Xpertdoc', 'Xp') = 1

containsc('Xpertdoc', 'xP') = 0

containsc('Xpertdoc', 'Xu') = 0

containsc('Xpertdoc', 'u') = 0

startsWith

Returns 1 if c starts with s, 0 if it doesn't. Case is ignored.

startsWith(c, s)

startsWith('Xpertdoc', 'xp') = 1

startsWith('Xpertdoc', 'X') = 1

startsWith('Xpertdoc', 'oc') = 0

startsWith('Xpertdoc', 'Oc') = 0

startsWithC

Returns 1 if c starts with s, 0 if it doesn't. Case-sensitive.

startsWithC(c, s)

startsWithC('Xpertdoc', 'xp') = 0

startsWithC('Xpertdoc', 'X') = 1

startsWithC('Xpertdoc', 'oc') = 0

startsWithC('Xpertdoc', 'Oc') = 0

endsWith

Returns 1 if c ends with s, 0 if it doesn't. Case is ignored.

endsWith(c, s)

endsWith('Xpertdoc', 'xp') = 0

endsWith('Xpertdoc', 'X') = 0

endsWith('Xpertdoc', 'oc') = 1

endsWith('Xpertdoc', 'Oc') = 1

endsWithC

Returns 1 if c ends with s, 0 if it doesn't. Case-sensitive.

endsWithC(c, s)

endsWithC('Xpertdoc', 'xp') = 0

endsWithC('Xpertdoc', 'X') = 0

endsWithC('Xpertdoc', 'oc') = 1

endsWithC('Xpertdoc', 'Oc') = 0

Other

Function Name

Description

Syntax

Example

getLoopIndex

Returns the number of the current iteration, with the first iteration being 0. This can be useful in loops. Example: making your own numbered lists.

getLoopIndex()

If you have nested loops, you can get a higher level loop's current iteration by specifying how many levels up you want to look. For instance, if you have loops A, B and C where C is inside B and B is inside A:

Nested loop

Iteration

Inside of loop C

  • getLoopIndex() = return the iteration of loop C
  • getLoopIndex(0) = return the iteration of loop C
  • getLoopIndex(1) = return the iteration of loop B (1 level up)
  • getLoopIndex(2) = return the iteration of loop A (2 levels up)

Inside of loop B

  • getLoopIndex() = return the iteration of loop B
  • getLoopIndex(0) = return the iteration of loop B
  • getLoopIndex(1) = return the iteration of loop A
  • getLoopIndex(2) = invalid (there is no loop 2 levels up)

Inside of loop A

  • getLoopIndex() = return the iteration of loop A
  • getLoopIndex(0) = return the iteration of loop A
  • getLoopIndex(1) = invalid (there is no loop 1 level up)
  • getLoopIndex(2) = invalid (there is no loop 2 levels up)

safeValue

Returns c unless an error occurs, in which case d is returned. If d is not specified, null is used. This function can be useful when you cannot guarantee that the value will be what you need. For instance, further calculations expect a number, but the field may also hold a string. Using this function guarantees that the document generation continues - it may not be with the expected result, but at least you can catch this instead of running into an error.

safeValue(c,d)

 

valueOrDefault

Returns c unless it is null, in which case d is returned. This function can be useful when you must avoid null values. Null values are, for instance, empty fields (for numbers or dates).

valueOrDefault(c,d)