Web · CLI · Source · Configuration
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.
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 use the tool 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 image by typing the following command in a terminal window:
docker pull lekojson/greenlight
Then you can then start the container with the command:
docker run -it -p 8080:8080 lekojson/greenlight server
You can also start the container via Docker Desktop, find the downloaded image and click on start:
When the container is running you can use the web interface by opening a web browser and type the address http://localhost:8080/, and then click on Begin validating to start a new validation session.
Configuration
First you select which schema/profile to use in the validation. In the current version three default schemas are available; NeTEx Standard, NeTEx Light and EPIP. In a future version of the tool it will be possible to upload your own local schema.
The next step is to select which additional rules you want to check. You first get an overview and brief description of each rule. Zero or more rules can be selected by clicking the rules in the list box.
The last step is to upload the files to be validated, it can be single files or multiple files compressed in an archive. Click Upload files to select which files to upload and then wait until all files has been uploaded, see the Status indicator in the files list.
When all files are uploaded you start the validation by clicking on Validate.
The validation will start by validating each file against the selected schema and rules. Depending on the number of files and their sizes the validation can take some time to complete. When the validation is done the result for each file is displayed. You can also download the result in json or csv format to a local file to process it further.
- Docker installed and ready to go
Note: if you don't have NeTEx xml document (or two) ready to test with we provide a few demo files in the source and docker image
- Getting the latest image
docker pull lekojson/greenlight
-
Running a validation
docker run -it lekojson/greenlight validate -i testdata
docker run -it -v /path/to/documents:/documents lekojson/greenlight validate -i /documents
Note: Greenlight is using Go and is powered by libxml2, so make sure those are installed and configured
- Clone repository
git clone https://github.com/ITxPT/DATA4PTTools
- Navigate to project
cd DATA4PTTools
- Downloading dependencies
go get
-
Building and running a validation
changes in path definition will differ running on windows
go run cmd/*.go validate -i testdata
changes in path definition will differ running on windows
go run cmd/*.go validate -i /path/to/documents
- Buliding and running the backend server
go run cmd/*.go server
- Building and running the frontend application
cd app
npm i
npm run dev
- Open a browser and navigate to
http://localhost:3000
Configurations can be made in a three different ways (in order of priority), through command line arguments, environment variables and configuration file
docker run -it lekojson/greenlight --help
or by command
docker run -it lekojson/greenlight [command] --help
docker run -it lekojson/greenlight validate -i testdata -o json
Environment comes with the prefix GREENLIGHT_
and match the paths (separated by _
) in configuration file (see below). Three different datatypes are supported, string
, boolean
and string slice
which also match the configuration file.
docker run -it -e GREENLIGHT_INPUT=/path/to/documents lekojson/greenlight validate