Altova FlowForce Server 2024 Advanced Edition

Expression Language Rules

Home Prev Top Next

To avoid errors in FlowForce expressions, follow these rules:

 

Use only allowed or declared values.

To use a string literally, enclose it within single quotes.

To embed an expression in a string field, enclose it within curly braces, that is, the { and } characters.

The expression must produce a data type which is meaningful in the field where the expression was entered.

 

Let's now have a look at these rules in more detail.

 

Rule #1: Use only allowed or declared values

The following constructs are allowed in FlowForce expressions:

 

FlowForce expression functions (for complete reference, see Expression Functions )

FlowForce operators (see Operators )

Numeric values

String values

Previously declared variables

 

When you type text inside a field which allows FlowForce expressions, a real-time syntax check takes place. If the syntax is not correct, FlowForce highlights in red the offending characters. Below is an example of a syntax validation error:

expression_error01

The error occurs because neither source nor target have been declared in the job, so FlowForce cannot interpret the expression. The problem can be fixed by declaring these values (for example, as job input parameters):

expression_error02

 

Rule #2: Enclose strings in single quotes

If you need to use a string literally, enclose it within single quotes. Otherwise, the expression might produce undesired results or validation will fail. Consider the following examples:

 

Expression

Will be evaluated as...

Explanation

expression_in_compute01

2

The data type of the value is numeric.

expre_1plus1_string

1+1

The data type of the value is string.

expression_in_compute02

true

The data type of the value is Boolean.

 

When you need to convert values from one data type to another, use the FlowForce expression functions (see also Rule #4).

 

Rule #3: Use curly braces in string fields

If you want to embed an expression inside a string field, enclose the expression within curly braces. In the example below, curly braces delimit the expression instance-id() (which is a FlowForce expression function) from the rest of the string.

expression_in_string05

 

If the entire field is of type "as expression", do not use curly braces. For example, the Expression parameter of the system/compute built-in function has this type. Below is an example of a correct value for this field (notice no curly braces are used):

expression_correct

 

Typing curly braces inside the expression field would trigger a syntax error:

expression_incorrect

 

See also Embedding Expressions in String Fields.

 

Rule #4: Use the correct data type

Finally, be aware that FlowForce performs data type checks when you save a job. An error will occur if the expression entered in a field does not match the data type expected by the field. You can see the data type expected by each field displayed on the right side of it, for example:

expression_field_type

 

Therefore, an expression such as 1+1 is not a valid in a string field, because it is implicitly evaluated as numeric. On the other hand, the expression '1+1' is valid in a string field. Consider the following examples:

 

Expression

Will be evaluated as...

Explanation

1/4

0.25 (as Number)

The data type of the value is numeric.

 

Use this expression in a field or context which expects a numeric value; otherwise, job validation would fail.

1+1==2

true (as Boolean)

The data type of the value is Boolean.

 

Use this expression in a field or context which expects a Boolean value; otherwise, job validation would fail.

'apple'

apple (as String)

The data type of the value is string.

 

Use this expression in a field or context which expects a string value; otherwise, job validation would fail.

concat('1','2','3')

123 (as String)

The data type of the value is string.

 

Use this expression in a field or context which expects a string value; otherwise, job validation would fail.

1+'apple'

-

This expression is not valid, and FlowForce will return an error when you attempt to save the job. Evaluation cannot take place because two different data types (string and numeric) are being compared.

{content(stdout(result))}

[...] (as String)

 

 

This expression uses two nested expression functions:

 

The function stdout gets the standard output of a shell command, as stream.

The function content converts the stream value to a string.

 

Although the expression is correct, the job will validate successfully only when the following is true:

 

The value "result" has been previously declared.

The value "result" actually contains the standard output of a shell command.

The expression is embedded into a string field.

 

See also Calling Expression Functions.

© 2017-2023 Altova GmbH