Understanding the eForms SDK

The eForms regulation requires the creation, and the submission for publication, of several types of public procurement notices. A developer of eForms applications needs to create applications that:

  • let a user fill in the right form for the type of notice that they want to publish;

  • validate the data that the user enters, to make sure that it complies with the eForms business rules;

  • save the data of the notice in the eForms UBL/XML format;

  • submit the XML for publication through an API.

A developer of eForms applications may also want their application to:

  • search for and retrieve notices;

  • visualise published notices or draft notices.

The purpose of the eForms SDK

The eForms SDK models the eForms specification in a formal way, so that the Publications Office can manage change and limit its impact.

The information systems of the Publications Office, together with the eForms applications of eSenders, form a large network for the notification of public procurement. This network needs to work as one, and to follow the changes of the legal and business environment. To limit the impact of change on this network, the idea is that the network applies changes, as far as possible, by updating metadata rather than by changing programs.

The Publications Office shares the eForms SDK publicly, so that the community of developers can benefit from the work that it does for its own implementation of eForms.

As an application developer, you can choose to analyse the latest regulation and eForms schemas yourself, and to program the business rules and notice forms. You can then model the eForms specification in your application in the way that best fits your purposes and your business environment. This is a valid approach. However, a "traditional application" takes several times the effort to create and maintain that an "application driven by metadata" takes. As long as you create and submit valid notices, and follow the changes of the business environment, any solution that you choose for the implementation of eForms is valid.

If you decide to implement eForms without the eForms SDK, see Implementing eForms without using the eForms SDK.

From the eForms regulation to a technical specification

The eForms regulation is a legal document, not a technical specification. However, the regulation and its annexes define some high-level technical requirements for the data that eForms notices collect and publish. For example, they define business terms and give each of them a data type. They also define business requirements, for example whether these business terms are mandatory, optional or even forbidden in certain cases.

When the Publications Office implemented the regulation in an information system, it had to resolve some points that the regulation itself leaves open. One of the aims of the eForms SDK is to settle these points in a formal way.

The impact of UBL/XML

The choice of UBL as the basis for the implementation of the eForms regulation also limits the choices of implementation. For example, some business terms of the regulation had to be added as extensions to UBL, while UBL already defined others, which could be reused. One of the aims of the eForms SDK is to add a layer of abstraction on top of both the eForms regulation and the UBL specification. This layer brings these two separate standards together into one implementation that leaves no room for different readings.

Business terms and fields: the XML structure in code

The business terms of the regulation are high-level concepts, which classify kinds of information. However, the same business term can behave very differently depending on where it is used. To resolve this, the eForms SDK introduces the concept of a field. A business term is represented by different fields in different contexts.

Unlike a business term, a field always stands for one specific place in the XML file of the notice, so it has an XPath. So a field can also have business rules: the validation can find its value and check it.

With the fields of the SDK, you can create an application that does not depend on the specific XPath of each field.

Repeatability, fields and nodes

Fields correspond to business terms, so they contain the data that the user enters. In XML terms, fields point to the end elements of the XML hierarchy, the elements that have no child elements.

The eForms regulation defines some business terms as repeatable. However, the XML specification, which is based on UBL, does not let some of the XML elements that correspond to fields repeat. In these cases, an XML element that contains them repeats instead. So fields alone are not enough to build the whole XML structure. This is why the SDK also introduces the concept of a node.

The conceptual model

The eForms SDK needs to bring together the high-level requirements of the eForms regulation and the low-level limits of UBL. It does so in a conceptual model. With this model, an application can build the physical structure of the notice data in an XML file, while it stays at the conceptual level of the business domain.

In this model, an eForms notice is a hierarchy of nodes and fields. Each field has a parent node. All nodes, except the root node, also have a parent node. The place of each field and node is defined relative to its parent, with XPath, because notices are stored in XML. A node can be repeatable, which means that it can occur more than once in its parent node. A field can also be repeatable. With the conceptual model, you can build the XML file of a notice without considering which specific fields it contains, or which rules apply to them.

You find the conceptual model in the file fields.json, in the folder fields of the eForms SDK (see Field metadata).

What is the benefit of the conceptual model?

The conceptual model is the central part that makes applications driven by metadata possible: applications that do not depend on business terms, eForms schemas, notice forms or business rules. So these applications can follow future changes of the eForms specification without being modified. Because all changes come through the SDK, as metadata, rather than as changes to programs, their impact is as small as possible.

Notice types: putting a form on the screen

The first aim of an eForms application that creates and submits notices is to collect the data of the notice from the user. The eForms regulation defines several types of notice, which serve different purposes.

To collect the data, the application needs to show the user the right form. So that an application can create a notice form from metadata, the eForms SDK introduces the concept of the notice type definition. The SDK contains one notice type definition file, in JSON format, for each type of notice.

A notice type definition is a set of input fields, organised in a hierarchy of display groups. This gives the notice a visual structure. The visual structure cannot be the same as the physical structure that stores the data in an XML file. The visual structure must follow how the user who fills in the form sees a notice, not how an XML file stores data.

You find the notice type definitions, in JSON format, in the folder notice-types of the eForms SDK. An index file, notice-types/notice-types.json, gives metadata about each notice type (see Notice Types).

Why create the forms from metadata?

Forms programmed by hand would have to change each time that the specification changes. When applications create the forms from metadata, the forms can change without any change to the applications. Because all changes come through the SDK, as metadata, rather than as changes to programs, their impact is as small as possible.

Business rules: validating notices

One of the main aims of the eForms regulation was to lay the basis for better use of data, and for better quality of data, in the notification of public procurement. Checks of the quality of data, through validation, have become a central part of the implementation of eForms by the Publications Office.

To this end, the TED Central Validation Service maintains and applies a complete set of business rules, which all submitted notices must meet. It applies these rules to the XML files with the Schematron validation engine.

Types of business rules

There are several types of business rules:

  • Some business rules check how XML notices are made up. For example, they check whether a particular field is allowed in a particular notice type.

  • Other business rules check that the user has filled in all mandatory fields.

  • Business rules can also limit the values submitted. For example, some business rules check the form of the values of text fields, with patterns, or the range of the values of numeric fields.

  • Business rules also limit the possible values of one field according to the value entered in another field. These rules are called "co-constraints". Co-constraints can depend on the values of other fields of the same notice, but they can also look up values submitted in other notices.

Business rules in the SDK

The eForms SDK defines in a formal way what a business rule is, how it is written and what it can do:

  • Each business rule applies to a field: the field that the rule validates.

  • Each business rule applies to specific notice types.

  • Each business rule has a precondition. The rule applies only when the precondition is true.

  • Each business rule has a test. This test is a logical operation that decides whether the notice meets the rule.

The validation applies a business rule by evaluating its test. It evaluates the test only:

  • for the occurrences of the field to which the rule applies;

  • in the notice types to which the rule applies;

  • when the precondition is true.

Validation environments

The Central Validation Service (TED CVS) applies all business rules to the XML of notices. TED CVS uses the Schematron validation engine, so for this environment all business rules are written as Schematron rules.

However, the TED Central Validation Service is not the only environment in which business rules need to run.

Many business rules can also guide the user while they fill in their notice. For example, a business rule that checks, while the user fills in the form, whether the user has given a mandatory value makes the form easier to use. In the same way, if the form evaluates co-constraints while the user fills it in, the user better understands what information they must give, according to the values that they are entering.

So the eForms SDK recognises two separate validation environments:

  • the environment of a tool for filling in forms;

  • the environment of a service that validates XML.

In the environment of a tool for filling in forms, validation happens while the user is still filling in the notice form. So the validation does not yet have a complete XML file of the notice. In such an environment, the validation can evaluate only the business rules that do not need a complete notice. The eForms SDK shares these rules as constraints attached to each field, in fields/fields.json.

In the environment of a validation service, the validation checks a complete XML file of a notice, and can apply all business rules. In this case, the validation always works on XML, so the SDK assumes that it is based on XSLT, either directly or through a validation engine such as Schematron.

Formal expression of business rules

The eForms SDK needs to make each business rule available to different validation environments. For this, each business rule needs a formal form that can move from one environment to another. For this formal form, the eForms SDK introduces a language made for the domain of eForms, called "eForms Expression Language" (EFX).

What is the benefit of writing business rules formally?

Business rules are first written in plain English. However, for a validation engine to run them, they need to be written in the language of that validation engine. Writing the business rules in EFX has these benefits:

  • It leaves no room for different readings.

  • The rules can be checked, through syntax checking and type checking.

  • The rules are written only once, but can be reused in any environment.

  • You can reuse the rules too.

Validation with Schematron

As described above, the TED Central Validation Service uses Schematron to validate the submitted XML files of notices. The folder /schematrons of the SDK gives you all the Schematron validation rules that TED CVS uses.

Schematron rules use an XSLT transformation to produce the validation reports that TED CVS returns. Each rule applies to a specific context, defined in XPath, and contains assertions that test whether specific conditions are met. These conditions (tests) are also written in XPath.

The Publications Office does not maintain the XPath expressions of the Schematron files in XPath. It maintains them in EFX, and translates them into XPath automatically each time that it generates a new version of the SDK.

The EFX grammar

As the previous section explains, EFX exists so that the business rules are written in only one language, and can still be translated into any other language that each application of the TED network needs.

To define a new language, you must define its rules of spelling and of syntax in a precise way, so that a processor for the new language can be built. A language processor is a part of an application that reads an expression, or a program, written in that language. It either runs it directly, or translates it into another language, which another processor can run.

To make it simpler to build a parser for EFX, so that anyone can build their own EFX processor, the Publications Office defined EFX with ANTLR 4, a widely used parser generator. ANTLR 4 takes the grammar of a language as input, and generates a parser for that language, ready for use on several development platforms, such as Java and .NET. Developers can then extend the generated parser to process EFX expressions, that is, to run them or to translate them into another language that fits their systems.

What is a parser?

Parsing is the task of breaking down a text written in a computer language and recognising its instructions. It is the core activity of every language processor. A parser is the program that does it.

The eForms SDK includes the EFX grammar, so that applications always read EFX expressions with the right version of the grammar.

Several resources of the SDK depend on the syntax of EFX:

  • EFX expressions express the constraints, in fields/fields.json.

  • EFX templates define the templates for the visualisation of notices, in the folder view-templates.

  • The Schematron rules, in the folder schematrons, are also generated by translating EFX expressions into XPath.

Why create EFX instead of using an existing language?

The Publications Office considered existing expression languages, such as SpEL. However, these languages were too general, and would have left some business rules open to different readings. With an existing language that is not made for the domain, the Publications Office would have had to add conventions and meanings that the language itself does not cover. So a language made for the domain was the best choice. It is as open, and as easy to move between environments, as any existing expression language. It also gives more control over what each part of the language means, and can be adapted to the needs of eForms.

Changes to the EFX grammar that would make existing expressions invalid come only with a new major version of the SDK. So every EFX expression that is valid in one minor version or patch of the eForms SDK stays valid in the later minor versions and patches of the same major version.

To learn more about EFX, see eForms Expression Language (EFX).

View templates

The obvious way to present an XML notice in a form that people can read and share is a style language built for XML. The eXtensible Stylesheet Language (XSL) was designed for this purpose. It has been the common standard since the W3C introduced it in 1999.

An XSL transformation (XSLT) would usually be enough to visualise an XML file of a notice in almost any format. However, a solution based only on XSLT would cause a problem in a network such as TED. TED is a network of information systems, made of many applications that different organisations build separately, with different business and operational environments, in all the Member States of the EU. The problem with XSLT is that it mixes "style", "form" and "logic" into one transformation. This does not suit the TED network, because all visualisations in all Member States would then be either identical or not reusable.

So the network needs a way to separate these three parts of a transformation (style, form and logic). Applications and Member States can then share and reuse a common "logic", and still adapt the "form" and "style". Templates make this separation possible.

EFX already covered the need to find and read the values of fields in an XML file, and to compute with them. So the Publications Office could take the "logic" out of the transformation, and put it entirely in an EFX template. An EFX template makes a few basic assumptions about "form", and gives the information needed to visualise an XML file of a notice. Applications can reuse this information, and still adapt the presentation freely.

The assumption that EFX templates make about "form" is that a visualised notice is a text document with a hierarchical structure. This structure comes from the need to arrange the information in the sections of the notice, and to group related information under different levels of headings. EFX templates set no limits on how these parts look or behave in different applications.

So an EFX template is a series of template lines, which you can nest with indentation. Each line holds all the logic of the visualisation, with two pieces of information:

  • "where to go" in the XML document. This is called the context. Any XML processor, including XSLT, needs it to keep a current position in the XML document.

  • "what to display" on the screen. This is a combination of EFX expressions, references to labels (from /translations) and fixed text.

For more information on EFX view templates, see Notice View Templates.

Translations

While it implemented eForms, the Publications Office defined, collected and organised in the eForms SDK all the kinds of parts that make up the eForms specification: the parts of the conceptual and visual models, the formal business rules, and so on. It also needed clear labels for these parts in all the official languages of the EU.

So the aim was to find all the terms that needed a label, and to define the kinds of labels that each kind of term needed. The Publications Office then organised and managed this information centrally, so that all eForms applications can share it.

The result of this work became the content of the folder /translations of the eForms SDK. The translations are organised in a simple way:

  • Every kind of part of the eForms SDK has labels. These kinds of parts are called asset types.

  • Every asset type has one or more labels, from a fixed set of labels called label types. Every asset type has a name, a description and a hint label. Some additional label types cover special cases.

  • Each label has an identifier. These identifiers are designed so that a developer can work out the identifier of any label that they need.

    For example, to find the description of a specific field, you build the label identifier from the asset type, the label type and the asset identifier. For the description of a field, the asset type is field, the label type is description, and the asset identifier is the identifier of the field.

  • Each label has a text translated into all the official languages of the EU. With the label identifier and the language identifier, you can find and reuse any label of the eForms SDK.

To find out more about the translations of procurement labels, see Procurement labels and translations.

Examples

Example notices, often used as test data, are very helpful during development. During its own implementation, the Publications Office found it difficult to obtain them. The folder /examples of the SDK shares examples of XML files of eForms notices, which the Publications Office also uses in its tests. The Publications Office adds more examples to the SDK as it creates more XML files of notices.

The folder /examples/notices also contains some XML files of notices that are invalid on purpose, and fail validation by the Central Validation Service (TED CVS). These examples show errors, and come with the matching TED CVS validation reports, in the folder /examples/reports.

If you have other examples that you think others can benefit from, you are welcome to share them, so that the Publications Office can distribute them in future releases of the SDK. Submit them for review and inclusion in the SDK through GitHub pull requests.

eForms SDK versions

The way in which the eForms SDK numbers its versions is at the core of the management, maintenance and evolution of the eForms specification. It is so important because it gives a framework both to channel change and to manage it.

The basic idea of the version numbers of the SDK is that all changes fall into one of the following three categories:

  • Changes that require adaptations in applications driven by metadata.

    • Shown by a change of the major version number of the SDK.

    • Impact: all applications.

    • Handling: a new version of your application adds support for the new SDK.

  • Changes that affect the results of notice validation.

    • Shown by a change of the minor version number of the SDK.

    • Impact: none for applications driven by metadata.

    • Handling: added as a new, separate version to the SDK versions available to the application.

  • All other changes.

    • Shown by a change of the revision (patch) number of the SDK.

    • Impact: none for applications driven by metadata.

    • Handling: replaces the previous revision.

Make sure that you read the page eForms SDK Versioning to understand how the versions of the SDK work.

How the Publications Office builds and maintains the SDK

The Publications Office does not maintain the eForms metadata of the SDK in the text formats in which it distributes them. It stores, organises and maintains all eForms metadata in a relational database. A web application, "eForms Metadata Management", serves to maintain the metadata and prepare future releases.

When a new release of the SDK is ready, a dedicated application reads the metadata from the eForms metadata database, converts it into the text formats of the SDK, and packages it for distribution. The release process is not fully automatic, but it is well organised: people check it, but do not change the data by hand.

The file formats of the eForms metadata come from the practical needs of the applications of the Publications Office. Today, JSON and XML are the main file formats of the SDK. If you need other file formats, such as YAML, or have suggestions for improvements, please share them in the eForms SDK Discussions on GitHub.