EFX Language Reference
The eForms Expression Language (EFX) is the language of the eForms SDK for three tasks: computing values from the data of a notice, validating notices, and displaying them. This reference describes the language construct by construct: what each construct is for, how you write it, what it does, and which restrictions apply.
The reference is for everyone who reads or writes EFX: the authors and reviewers of validation rules and view templates, the developers of eForms applications, and anyone who wants to understand an EFX expression of the SDK. You do not need to know XPath or any programming language to use it.
This reference describes EFX-2, the version of the language that comes with eForms SDK 2.
The three flavours of EFX
EFX comes in three flavours, each with its own purpose:
- EFX Expressions
-
An expression computes a value from the data of a notice: a text, a number, a date, or whether a condition is met. You use expressions on their own, for example in the field metadata of the SDK to state when a field is mandatory, and inside the other two flavours.
- EFX Templates
-
A template file describes how a notice is displayed: which information is shown, in which order and hierarchy, and with which labels. The view templates of the SDK are written in EFX Templates.
- EFX Rules
-
A rules file describes how a notice is validated: which conditions the data must meet, at which validation stage, for which notice subtypes, and how serious each problem is. The validation rules of the SDK are written in EFX Rules.
Templates and rules both add constructs of their own to the syntax of expressions. All three flavours share the same foundations: how you refer to the data of a notice, the context from which an expression is read, and the data types.
How this reference is organised
- Foundations
-
What the three flavours share: how EFX text is written, how the data of a notice is organised, the context, the data types and type checking.
- Expressions
-
The constructs of EFX Expressions: the forms of an expression, literals, references to the data of a notice, variables, operators, conditional expressions, sequences and iteration, function calls, and regular expressions.
- Built-in functions
-
All the functions of the language, in groups, with an alphabetical list.
- Templates
-
The constructs of EFX Templates: the structure of a template file, declarations, sections, template lines and the content of a line.
- Rules
-
The constructs of EFX Rules: the structure of a rules file, declarations, validation stages, rule-sets and the clauses of a rule.
- Appendices
-
Operator precedence, Type conversions, Syntax summary, Keywords, Changes from EFX-1, Glossary and an alphabetical Index.
How to read an entry
Each construct, operator and function has its own entry, and all entries have the same structure:
-
a sentence that says what the construct is and what it is for;
-
Syntax: the forms in which you write the construct (see Syntax notation);
-
the meaning of each part of the syntax;
-
a description of what the construct does: its context, its types, how it is evaluated and what it gives;
-
Restrictions: what is not allowed;
-
Examples. When the context of an example does not matter, the example shows the expression on its own. When it matters, the example shows a complete expression with its context:
WITH <context> COMPUTE <expression>; -
a note labelled EFX-1, when the construct differs from EFX-1;
-
See also: related entries.
Syntax notation
A syntax block shows how you write a construct:
-
Keywords, symbols and punctuation appear exactly as you write them in EFX, for example
WITH,COMPUTE,${and;. -
A name between angle brackets, such as
<expression>, stands for a part that is explained below the syntax block or in another entry. -
When a part is optional, or when there are alternatives, each form appears on a line of its own. Square brackets and parentheses always belong to EFX itself.
-
The ellipsis
…means that you can repeat the part before it. It is a single character, not the three dots...that EFX uses in codelist references.
Keywords appear in the case that EFX requires: the keywords of statements, such as WITH and ASSERT, in upper
case, and the keywords of expressions, such as and and every, in lower case (see
Case sensitivity).
Fields and nodes used in the examples
The examples use a small set of fields and nodes made for illustration, not real eForms fields. Their identifiers include the data type of the field, so you can see the type of every value in an example at once. The EFX Toolkit uses the same fields for its own tests, and every example in this reference has been checked with the toolkit.
The nodes form the following hierarchy. A repeatable node can occur more than once in a notice.
ND-Root
├── ND-SubNode
│ ├── ND-SubSubNode
│ ├── ND-SubSubNode2
│ ├── ND-RepeatableInSubNode (repeatable)
│ └── ND-RepeatableInSubNode2 (repeatable)
└── ND-RepeatableNode (repeatable)
├── ND-NonRepeatableSubNode
│ └── ND-RepeatableSubSubNode (repeatable)
├── ND-NonRepeatableSubNode2
├── ND-RepeatableInRepeatableNode (repeatable)
└── ND-RepeatableInRepeatableNode2 (repeatable)
Field identifiers have the form BT-<n>-<type>. The number shows where the field is, and so whether a reference to
it from the root gives a single value (scalar) or a sequence of values:
| Fields | Located in | From the root, a reference gives |
|---|---|---|
|
|
a single value |
|
|
a single value |
|
|
a sequence |
|
|
a sequence (their ancestor repeats) |
|
|
a sequence |
|
|
a sequence |
The last part of the identifier gives the type. For example, BT-00-Text, BT-00-Number, BT-00-Indicator,
BT-00-StartDate, BT-00-StartTime, BT-00-Duration, BT-00-Code and BT-00-Text-Multilingual are fields of
ND-Root, and BT-13-Text is a text field of the repeatable node ND-RepeatableInSubNode.
Versions
EFX-1 is the version of the language that SDK 1 uses. EFX-2 extends it with many constructs. In a few places, EFX-2 also changes EFX-1, to make the language more precise and to detect more errors, so you must adapt some EFX-1 expressions. When an entry differs from EFX-1, a note labelled EFX-1 says how. An entry without such a note works as in EFX-1. The appendix Changes from EFX-1 lists the changes that are not backward compatible.