EFX Toolkit for Java developers
The EFX Toolkit for Java developers is a library that translates EFX expressions, templates and rules into other languages, called target languages. The Publications Office develops the library and uses it in its TED applications. It is available on GitHub for developers of eForms applications in Java. You can use it in your applications, and propose improvements and corrections through pull requests.
| If your application is not written in Java, you can build your own translator with ANTLR 4 and the EFX grammar (see EFX grammar). |
Functions of the toolkit
The toolkit does the parts of the translation that are the same for every target language:
-
Parsing: it reads expressions, templates and rules with ANTLR 4 and the EFX grammar, and finds their structure.
-
Type checking: it applies the type rules of EFX, including the types that only the SDK metadata gives.
-
Scope management: it keeps track of the variables that are visible at each place, of the context, and of the values under evaluation.
-
Symbol resolution: it finds the metadata of eForms fields and nodes, such as their paths, types and repeatability.
You provide what is specific to your target language by implementing a few interfaces.
EFX translators
The toolkit provides three translators, one for each flavour of EFX:
| Translator | Purpose | Output |
|---|---|---|
|
Translates single EFX expressions |
A target scripting language, for example XPath |
|
Translates EFX view templates |
A target markup language, for example XSLT |
|
Translates EFX validation rules |
Validation files, for example Schematron |
EfxTemplateTranslator and EfxRulesTranslator both extend EfxExpressionTranslator: they translate expressions in
the same way, and add what is specific to their flavour.
To choose the right translator for your application, see Choosing a translator.
Core interfaces
Every translator needs implementations of these two interfaces:
SymbolResolver-
Finds the metadata of the symbols of the eForms SDK: fields, nodes and codelists. The toolkit provides
SdkSymbolResolver, which reads the metadata directly from the eForms SDK. Most applications can reuse it without changes. ScriptGenerator-
Writes code in the target scripting language. The toolkit provides
XPathScriptGenerator, which writes XPath.
Depending on the translator that you use, you also need one of these:
MarkupGenerator-
Writes the output of templates in the target markup language.
EfxTemplateTranslatorrequires it. The Notice Viewer sample application contains an implementation that writes XSLT,XslMarkupGenerator. ValidatorGenerator-
Writes validation files from the model that the rules translator builds.
EfxRulesTranslatorrequires it. The toolkit providesSchematronGenerator, which writes Schematron.
Recommended reading
| Getting started | |
| Choosing a translator | |
| Implementing a generator |
the Implementation guide, starting with The expression and markup model |
| Architecture |
Type system internals, Call stack architecture, Symbol resolver architecture |