https://github.com/viaacode/mtd-transformer
Microservice to perform XSLT metadata transformations.
https://github.com/viaacode/mtd-transformer
chassis-py python saxon xslt
Last synced: 4 months ago
JSON representation
Microservice to perform XSLT metadata transformations.
- Host: GitHub
- URL: https://github.com/viaacode/mtd-transformer
- Owner: viaacode
- License: gpl-3.0
- Created: 2019-10-29T14:12:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T15:48:48.000Z (about 2 years ago)
- Last Synced: 2024-04-24T05:40:50.733Z (about 2 years ago)
- Topics: chassis-py, python, saxon, xslt
- Language: XSLT
- Homepage:
- Size: 5.19 MB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Metadate transformation service
Transforms given metadata to a new format based on a chosen transformation.
For XML-to-XML transformations Saxon HE is used under the hood. Saxon HE is (c) Michael H. Kay and released under the Mozilla MPL 1.0 (http://www.mozilla.org/MPL/1.0/)
## Prerequisites
- Python 3.8
- Java (for running Saxon HE)
## Installation
1. Clone or download the repository
2. `cd` into the directory
3. Create a virtual environment `python -m venv .`
4. Activate the environment `source bin/activate` on Linux or `Scripts/activate` on Windows.
5. Install dependencies `pip install -r requirements.txt`
## Usage
### CLI
Using the CLI you can transform a file and list the available transformations.
Output of `python cli.py --help`:
```
Usage: cli.py [OPTIONS] COMMAND [ARGS]...
Coole CLI voor metadata transformaties
Options:
-v, --verbose
--help Show this message and exit.
Commands:
list List all available transformations.
transform Transforms an input file based on a given transformation.
validate
```
#### Example
`python cli.py transform --help` will give more information about the parameters.
`python cli.py transform` will prompt for an input file and a transformation.
`python cli.py transform -i C:\test.xml -t OR-rf5kf25` will transform `C:\test.xml` using the transformation specified in `./resources/OR-rf5kf25` and output the result to `stdout`
`python cli.py transform -i C:\test.xml -t OR-rf5kf25 -o C:\output\test.xml` will transform `C:\test.xml` using the transformation specified in `./resources/OR-rf5kf25` and output the result to `C:\output\test.xml`
### API
Run `python app.py` to start the service. You will be using the Flask development server.
#### Example
To transform an XML-file, send a `POST` request to `http://0.0.0.0:5000/transform?transformation=OR-rf5kf25` with the xml in the body.
Add `application/xml` to the `Content-Type` header.
HTTP-call:
```HTTP
POST /v1/transform?transformation=OR-rf5kf25 HTTP/1.1
Host: 0.0.0.0:5000
Content-Type: application/xml
2019-11-28T11:44:00.327+01:00
titel test viaa item
```