Changes from EFX-1
EFX-2 extends EFX-1 with many new parts of the language, and with a new flavour, EFX Rules. In a few places, it also changes EFX-1, to make the language more precise and to find more errors. In those places, you must adapt an expression or a template written for EFX-1 before you can use it with EFX-2. This appendix lists these changes first, then the one EFX-1 name that EFX-2 still accepts, then what is new. Each item links to the entries that describe it.
Changes that require EFX-1 expressions to be adapted
- Sequences in square brackets
-
You write a sequence of values as
['a', 'b'], no longer as('a', 'b'). See Sequence construction. - Codelist references
-
You refer to a codelist as
[...main-activity], no longer as(main-activity)or#main-activity. See Codelist reference. - No type name before a reference
-
In EFX-1, you could state the type of a reference before it, as in
number:BT-00-Number. EFX-2 does not need this, because the translator finds the type of every reference by itself: writeBT-00-Number. See Type checking. - The type
measureis nowduration -
The type name is
durationin the declarations of variables and parameters, and in iterators. The functionsadd-measureandsubtract-measureare nowadd-durationandsubtract-duration. See Duration. - Context overrides after a context variable only
-
Only a context variable can come before
:::$n::BT-21-Number. EFX-1 also accepted a field or a node there, as inND-RepeatableNode::BT-21-Number. You now write such a reference with an iteration or a context variable. See Context override. - Single expressions and template lines without braces
-
You now write:
-
a single expression as
WITH <context> COMPUTE <expression>, no longer as{<context>} ${<expression>}; -
a selector as
WITH <context> SELECT <selection>, no longer as{<context>} &{<selection>}; -
a template line as
WITH <context> DISPLAY <template>;, no longer as{<context>} <template>.See Expression forms and Template line.
-
- Outline numbers
-
A template line without a number no longer receives one automatically. Write
?at the start of a template line that relied on an automatic number, and remove the0of a template line without a number:0is no longer accepted. See Heading. - XPath axes removed
-
References such as
preceding::BT-…are no longer accepted. See Field reference. - References to other notices removed
-
References of the form
notice(…)/BT-…are no longer accepted. Rules files receive information from other notices through dynamic functions. See Dynamic function declaration. - Text-multilingual fields
-
A reference to a text-multilingual field gives the texts in all its languages, as a sequence. EFX-1 templates displayed the text in the preferred language automatically. In EFX-2, you select the language yourself. See Preferred language property.
- Meaning of
is empty -
In EFX-1,
X is emptywas true when the textXwas empty. In EFX-2, it is true whenXhas no value, for example when the field is absent. For the EFX-1 meaning, you now writeempty(X). See Emptiness andempty. - Fields with multiple values
-
You cannot compare a reference that can give several values as a single value. EFX-1 accepted
BT-13-Text == 'a', which was true as soon as one of the values matched. Because of this, mistakes could remain unnoticed, so EFX-2 reports such a comparison as an error. Write'a' in BT-13-Textinstead, or use a quantified expression. See Type checking and Quantified expression. - Regular expressions
-
The patterns of
likeandreplace-regexcan use only the parts of regular expressions that work in the same way in all target languages, and the translator checks them. See Regular expressions. - Special characters and words in template text
-
In the text of a template line, the characters
@,&,\and;have a special meaning. The wordsWHEN,OTHERWISEandINVOKE, in upper case and after a space, are keywords. See Text. - Colons in template text
-
In a template line that is not a heading, the first colon separates a caption from the content, and EFX does not display it. For a colon that EFX must display, write
\:, as inhttps\://example.com. Apart from colons written in this way, a template that is not a heading can contain only one colon. See Caption. - Grouping of operators
-
The conditions, such as
inandlike, apply before the comparisons, and EFX reads every level of operators from the left. If an expression relies on another grouping, you must add parentheses. See Parentheses and precedence. - Square brackets
-
A number in square brackets after a reference is not a position: square brackets without
athold a condition. To select one value by its position, use an index,[at 1]. See Index. - Functions
-
You can use
format-numberonly in templates, and you must give its picture.sequence-equalrequires two sequences of the same type.textgives numbers in a standard form that can differ from the EFX-1 output.
EFX-1 name still accepted
EFX-2 still accepts one EFX-1 name, to make the move from EFX-1 easier: the function name string, another name
for text. In new expressions, use text.
New in EFX-2
- EFX Expressions
-
-
the
WITH … COMPUTEform of a single expression, and selectors (WITH … SELECT), which return the occurrences that a reference points to (see Expression forms); -
types found by the translator for every part of an expression, and any single value accepted where a sequence is expected (see Type checking);
-
variables: declarations with
LET, variables in context declarations, sequence types, context variables and dynamic variables (see Variables); -
node references in presence conditions and in
count, several predicates after a reference, context overrides followed by a node, and the field properties, such as:rawValue,:privacyCodeor:publicationDate(see References); -
the conditions
has duplicatesandhas no duplicates,is unique infor any single value and sequence, and the addition and subtraction of a duration to and from a date (see Operators); -
indexes (
[at n]), iterations that return sequences, anddistinct(see Sequences and iteration); -
calls of user-defined and dynamic functions (see Function calls);
-
many new built-in functions, and conversions extended to more types (see Built-in functions);
-
comments in expressions and rules files, and statement keywords written in upper case (see Lexical structure).
-
- EFX Templates
-
-
global declarations at the start of a template file: variables, dictionaries and user-defined functions; template sections, which declare callable templates before the main section; a header section, a summary section and a navigation section after the main section; and include directives (see Template file and Sections);
-
the template line form
WITH <context> DISPLAY <template>;, variables in the context declaration, conditional display withWHENandOTHERWISE, template invocation withINVOKE, and bulleted lines (see Template lines); -
in the content of a line: the formatting of values by type and the format options of expression blocks, line breaks, line joining, hyperlinks, character references, escape sequences, computed label identifiers and the pluraliser (see Template content).
-
- EFX Rules
-
The whole flavour is new. SDK 1 delivered the validation rules as Schematron files, and used EFX-1 expressions for validation only in the constraints of the field metadata. In EFX-2, you write rules in rules files, with validation stages, rule-sets,
WITH EVERYand rules (see Rules file). Semantic assertions state what a rule requires of a field, in a form that client applications can use to prevent mistakes while the user enters the data (see Semantic assertion). Rule identifiers have the formR-XXX-XXXinstead of the formBR-…used in SDK 1.