This repository contains a Python library, command line script, and web application to convert LIDO XML files to RDF using X3ML mappings
The application can be installed with Docker (recommended) or from sources (for development).
Pull the current image
docker pull ghcr.io/nfdi4objects/lido-rdf-converter:mainand start a container with docker, or with docker compose and a docker-compose.yml like the one in this repository:
docker run --rm -p 5000:5000 ghcr.io/nfdi4objects/lido-rdf-converter:mainor
docker compose up --force-recreateRequires Python >=3.5 and a POSIX compliant operating system. Clone the repository, including its submodules:
git clone --recursive https://github.com/nfdi4objects/lido-rdf-converter.git
cd lido-rdf-converterThen install dependencies and missing submodules, and enable virtual Python environment:
make deps
. .venv/bin/activateWith Docker the command line client can be called like this:
cat example1.xml | docker run --rm -i ghcr.io/nfdi4objects/lido-rdf-converter:main lido2rdfAlternatively mount a volume to read and write files:
docker run --rm -v .:/data ghcr.io/nfdi4objects/lido-rdf-converter:main lido2rdf /data/example1.xmlIf installed from sources, call ./lido2rdf without any arguments or with --help for help:
usage: lido2rdf [-h] [-o NAME] [-t FORMAT] [-m MAPPING] [LIDO-XML]
Convert LIDO to RDF using X3ML mapping
positional arguments:
LIDO-XML LIDO file or URL (default: -)
options:
-h, --help show this help message and exit
-o NAME, --output NAME RDF output file (default: -)
-t FORMAT, --to FORMAT RDF output serialization (ttl,nt,json,xml)
-m MAPPING, --mapping MAPPING X3ML mapping file (default: defaultMapping.x3ml)
For instance this will convert example1.xml to example1.ttl:
./lido2rdf.py example1.xml -o examle1.ttlTo inspect how an X3ML mapping file is used internally:
./x3ml.py defaultMapping.x3mlThe web application is made available at http://localhost:5000 by default, if installed via Docker.
Usage if installed from sources is only recommended for development and testing.
If you want to run the web application by script, you have to install some JS scripts first. Therefore, you can use these shell commands:
cd ./static
npm ci
cd ../..Then start app.py (optionally with argument --port):
python app.pyThe API has not fully been specified yet an may change.
Convert LIDO/XML with default mapping. Returns RDF in Turtle serialization on success.
LIDO data can be send either via HTTP POST payload or as multipart/form-data file upload:
curl http://127.0.0.1:5000/convert --data-binary @lido.xml --silent
curl http://127.0.0.1:5000/convert -F file=@example.xml --silentTo locally build a Docker image for testing:
docker compose build- https://github.com/nfdi4objects/lido-schema contains schema files and validation script to check whether an XML file is valid LIDO (included as submodule into directory
lido-schema) - https://github.com/nfdi4objects/lido-examples contains sample LIDO files to be used as test cases
MIT License