Notice data

EFX works on the data of one notice at a time. The eForms SDK describes this data as a tree of nodes and fields, and EFX names them by their identifiers, never by their place in the XML document. This page describes that tree: the notice, its fields and nodes, the attributes of fields, the repeatability that decides whether a reference gives one value or several, and codelists. The page References shows how you write nodes and fields in an expression.

Notice

A notice is the document that EFX expressions, templates and rules work on.

An eForms notice is an XML document that follows the eForms schemas. Its notice subtype, such as 16 or E3, decides which fields it can contain. The SDK describes the content of notices in its field metadata (folder fields): the nodes that give a notice its structure, the fields that hold its data, and their properties.

An EFX expression always reads one notice, through references to its fields and nodes. Translators use the SDK metadata to find the data in the XML document, so expressions do not depend on the XML structure. The root of every notice is the node ND-Root, and all other nodes and all fields are below it.

Examples

WITH ND-Root COMPUTE ND-RepeatableNode is present

Tests whether the notice contains at least one occurrence of the node ND-RepeatableNode.

See also: Evaluation context

Field

A field is a part of a notice that holds a value, such as a title, a date or an amount.

The SDK metadata gives each field, among other properties, an identifier such as BT-00-Text, a type such as text, date or amount, the node that contains it, and whether it is repeatable. A field of type code or internal-code also has a codelist. Some fields have privacy settings, which give access to related information, such as the date from which a withheld value can be published (see Field property).

A reference to a field gives its value, with the EFX data type that corresponds to the type of the field (see Field types and their EFX data types). A field that is not in the notice gives no value. You test whether it is there with is present.

Examples

WITH ND-Root COMPUTE BT-00-StartDate < BT-00-EndDate

Compares two date fields.

WITH ND-Root COMPUTE BT-00-Text is not present

True when the notice does not contain the field.

Node

A node is a part of a notice that groups fields and other nodes, for example a lot.

The SDK metadata gives each node an identifier, such as ND-RepeatableNode, the node that contains it, and whether it is repeatable. ND-Root is the only node that no other node contains.

A node has no value: you cannot compare it or use it in a calculation. A node stands for a place in the notice, and you use it where a place is needed:

  • as the context of an expression, a template line or a rule-set;

  • in a presence condition;

  • in count, to count its occurrences;

  • with a predicate or an index, to select some of its occurrences;

  • in a context variable, to read fields from one of its occurrences with ::.

Examples

WITH ND-Root COMPUTE ND-RepeatableNode[BT-21-Number > 0] is present

True when at least one occurrence of the node has a value of BT-21-Number greater than 0.

WITH ND-Root COMPUTE count(ND-RepeatableNode) > 1

True when the node occurs more than once.

WITH ND-Root COMPUTE every context:$node in ND-RepeatableNode satisfies count($node::BT-23-Number) > 1

Takes the occurrences of the node one at a time, and reads a field in each.

Attribute

An attribute is a value attached to a field, such as the currency of an amount or the language of a text.

In the XML document, these values are in attributes of the XML element that holds the field: an amount has its currency in currencyID, a multilingual text has its language in languageID, and a code has the name of its codelist in listName. The SDK defines most of them as fields of their own, called attribute fields, which you refer to like any other field. The SDK field BT-36-Lot-Unit, for example, is the unit of the field BT-36-Lot.

You can also read an attribute by its name, with an attribute reference, as in BT-00-Text/@Attribute. Its value is a text.

You do not read the unit of a field of type duration separately: EFX combines the number and the unit into one duration (see Duration).

Examples

WITH ND-Root COMPUTE BT-00-Attribute == 'x'

BT-00-Attribute is an attribute field.

WITH ND-Root COMPUTE BT-00-Text/@Attribute == 'x'

The same attribute, read through an attribute reference.

Repeatability

Repeatability says whether a field or a node can occur more than once, and so whether a reference to it gives a single value (scalar) or a sequence of values.

In the SDK metadata, a field or a node is repeatable when it can occur more than once in the node that contains it. In an expression, however, what matters is whether a reference can give more than one value from the place where you write it, its context. A reference to a field gives a sequence when:

  • the field itself is repeatable; or

  • the field is a multilingual text, which holds one text for each language of the notice; or

  • there is a repeatable node on the path from the context to the field. The node of the context itself does not count, because the context is always one occurrence of it.

Otherwise, the reference gives a single value. So the same field can give a single value from one context and a sequence from another. An absolute reference, which starts with /, is read from the root of the notice, so every repeatable node above the field counts.

Repeatability is decided from the SDK metadata, before any notice is read. A reference that may give several values is a sequence, even when a particular notice contains only one value. Where a single value is required, for example in a comparison or a calculation, such a reference is an error. You can write the expression in other ways:

  • write it in a context from which the field gives a single value;

  • select one value, with an index such as [at 1];

  • combine the values, for example with count, sum or max;

  • test the values, with in, every or some;

  • take the values one at a time, with for … return.

The reverse is always accepted: where a sequence is expected, you can give a single value, which is read as a sequence of one value.

With the fields of the examples (see Fields and nodes used in the examples): BT-13-Text gives a sequence from ND-Root, because its node ND-RepeatableInSubNode is repeatable, and a single value from ND-RepeatableInSubNode itself. BT-23-Number gives a sequence from ND-Root and from ND-RepeatableNode, and a single value only from ND-RepeatableInRepeatableNode.

Examples

WITH ND-Root COMPUTE count(BT-13-Text) > 1

From the root, BT-13-Text is a sequence, which count accepts.

WITH ND-RepeatableInSubNode COMPUTE BT-13-Text == 'x'

From its own node, BT-13-Text is a single value, so you can compare it. From ND-Root, the same comparison is an error.

WITH ND-RepeatableNode COMPUTE sum(BT-23-Number) > BT-21-Number

From ND-RepeatableNode, BT-21-Number is a single value, and BT-23-Number is a sequence.

WITH ND-Root COMPUTE 'x' in BT-00-Text-Multilingual

A multilingual field is a sequence, with one text for each language.

In EFX-1, a reference to a multilingual field gave the text in the preferred language. In EFX-2, it gives the texts in all languages (see Text).

Codelist

A codelist is a list of codes: the values that a field of type code or internal-code can take.

The SDK metadata links each code field to a codelist, such as country or main-activity. The value of the field is one of the codes, for example FRA, and EFX reads it as a text. Some codelists are tailored: they contain only part of the codes of another codelist, for particular notice subtypes or fields.

A codelist reference, [...name], gives all the codes of a codelist as a sequence of texts. You mostly use it to test whether a code belongs to a codelist. In templates, you display the label of a code with a label block (see Label block).

Examples

WITH ND-Root COMPUTE BT-00-Code in [...authority-activity]
From the SDK (validation/rules.efx)
WITH BT-01-notice
  ASSERT BT-01-notice in [...legal-basis]
    AS ERROR R-F73-H6C
    FOR BT-01-notice
    IN *;

A rule that checks a code against a codelist.