The minimal, customizable, NeTEx validation tool
|
- Introduction
- Requirements
- Getting started
- Local installation
- Web interface
- Command Line Interface - CLI
- Validation rules
- Building from source
- More information
The tool consists of a number of components, each with a different responsibility. This will ensure that the tool is modular and that each component is easy to understand and maintain.
Component | Description |
---|---|
Core | - This is the main component of the tool, it reads the configuration, handles file imports, calls the validation scripts and summarizes the result. The Core provides an API that other components use to control the validation or to get access to shared functions, e.g, in libXML. The API also makes it possible to extend the tool with different front ends, as the CLI and Web Interface. |
libXML | - An open source, standard library integrated into the tool. It is libXML that does all the XSD and XML validation. It is called from the scripts via the API in the Core component. |
CLI | - The Command Line Interface is used in a terminal or integrated in an import/export pipeline. Parameters are used to configure the tool and to specify the files to be validated. The result can be read in the terminal or saved as a file. |
Web Interface | - Provides an easy to use interface via the web browser. The web interface makes the tool easer to use for the occasional user or for just testing small files. After loading the web page you can select the NeTEx profile to use, select one or more validation rules and then run the validation. After completion you get the result on the web page but can also download it to a file. |
Scripts | - Individual validation rules implemented as scripts. The scripts are written in JavaScript that is easy to start with and JavaScript is also well documented. The validation scripts are small programs that each implements one or more validation rules. The scrips provided with the tool implements one rule per script to make it easy to follow and understand how they work. To gain a better performance several rules can be implemented in the same script. Each script uses the API in Core to load the files to validate and to call functions in libXML. XPath provided via libXML is used by most of the scripts to search for and compare different elements in the NeTEx-files. |
To run the tool locally you must ensure that the machine used has the capability to handle the files to be validated. The validation times can be long and the tool can stop if the processing power or memory is to low. Below is a recommendation for the configuration of a machine. Be aware that very large or very many files affects the performance, and can result in longer validation times even on a machine with the recommended hardware.
Minimum | Recommended | Best performance |
---|---|---|
4 cores | 6 cores | 6 cores or more |
8 GB memory | 16 GB memory | 32 GB memory |
To try out the tool for the first time and evaluate the functionality you can use our hosted web interface at https://greenlight.itxpt.eu See Web Interface for an overview of how to use the tool with the visual interface.
If you find the tool useful and want to use it in more advanced scenarios, with larger files or include it in a pipeline, then you can download and install it locally in your own environment.
To use the tool locally, you need to install Docker on the computer that you will use. You can use Windows, Mac or Linux as your base operating system, and you will find Docker and instructions on how to install in the Docker Getting Started guide.
After you have installed Docker, you can get the latest version of the Greenlight image by typing the following command in a terminal window:
docker pull itxpt/greenlight
We suggest that you first start to use the web interface to verify that the installation works and to learn more about the functionality.
Start the web interface with the command:
docker run -it -p 8080:8080 itxpt/greenlight server
If you have used the image before, you can also start the web interface via Docker Desktop, goto to the Containers tab and press Start on the Greenlight container.
You can use the web interface by opening a web browser and type the address http://localhost:8080/ or you can access the online tool at the address https://greenlight.itxpt.eu/. Then you can click on Start validating to start a new validation session. You can also always use the New validation button in the upper right corner to start over with a new validation.
For mor details on how to use the web interface, see Manual for the web interface
The CLI is for more advanced use cases where you want more control over the validation or if you want to include the validation in your own pipeline. An example could be to recieve a file via an integration, validate the file with GreenLight and if there are any errors inform via email and otherwise save the file for use in another system.
To use the CLI you must first download the Docker image as described in Getting started
When you use the CLI you first give the command docker
and the parameters run -it [docker_image]
in this case the docker_image is itxpt/greenlight. After that you give the different commands and flags to greenlight, e.g., help
. If you want to use other docker parameters, you have to put them before the name of the image to use. See below for more complex examples of how to invoke the greenlight command.
For more details on how to use the CLI, see Manual for command line interface
The Validation Rules relevant to Greenlight NeTEx validator are mainly divided into two major categories:
- The rules based on XML schema
- The rules beyond XML schema
More information on the validation rules(the different rules, how to use them, how to build your own rules) is available in the wiki.
Greenlight is using Go and is powered by libxml2, so make sure those are installed first. If you want to work on the web interface you will also need Node.js
-
Download and install the latest version with standard settings
-
Install using
Mac:
brew install libxml2
Linux:
sudo apt install libxml2
Windows: Build from source or download precompiled binaries
-
nodejs - only required for the web interface
Download and install the latest version with standard settings
- Open a terminal and navigate to the folder where you want to install the source code.
cd /home/developer/code
- Clone repository
git clone https://github.com/ITxPT/DATA4PTTools
- Navigate to project
cd DATA4PTTools
- Downloading dependencies
go get
A dedicated section is available in the wiki to learn how to build the tool for source. You may also want to learn more about what you can find in the repository by going to this section of the wiki.
For further details on how to use Greenlight Data4pt tool, see our wiki