Skip to content
Snippets Groups Projects
Commit fe95ee98 authored by Thomas Bock's avatar Thomas Bock :speech_balloon:
Browse files

rdm

parent 98200c76
No related branches found
No related tags found
No related merge requests found
# xml-validation # xml-validation
HTTP-Server written in Python for validation of xml (e.g. DCC xml) against a REST service for the validation of ```xml``` against a XML Schema (```xsd```).
XML Schema.
## Installation ## Installation
``` ```shell
> git clone git@a75436.berlin.ptb.de:vaclab/xml-validation.git > git clone git@a75436.berlin.ptb.de:vaclab/xml-validation.git
> cd xml-validation > cd xml-validation
> python3 -m venv . > python3 -m venv .
...@@ -14,28 +13,51 @@ XML Schema. ...@@ -14,28 +13,51 @@ XML Schema.
> ./server > ./server
``` ```
The location of the ```xsd```-file can be configured in ```config.json```.
The default location is ```../xsd/dcc.xsd```:
```shell
├── xml-validation
│ ├── config.json
│ ├── README.md
│ ├── server
│ ├── server.py
│ ├── share
│ ├── utils.py
│ ├── xml-validation.service
│ └── xsd
└── xsd-dcc
├── dcc.xsd
├── documentation
├── examples
├── README.md
├── schemata
└── wiki
```
## API ## API
### /validate endpoint [POST] ### /validate endpoint [POST]
``` ```shell
> curl -X POST -H "Content-Type: text/xml" -d @valid_xml_matches_xsd http://localhost:5005/validate > curl -X POST -H "Content-Type: text/xml" -d @valid_xml_matches_xsd http://localhost:5005/validate
> <ok/> > <ok/>
``` ```
``` ```shell
> curl -X POST -H "Content-Type: text/xml" -d @no_valid_xml http://localhost:5005/validate > curl -X POST -H "Content-Type: text/xml" -d @no_valid_xml http://localhost:5005/validate
> <error>unvalid xml data</error> > <error>unvalid xml data</error>
``` ```
``` ```shell
> curl -X POST -H "Content-Type: text/xml" -d @valid_xml_but_dont_matches_xsd http://localhost:5005/validate > curl -X POST -H "Content-Type: text/xml" -d @valid_xml_but_dont_matches_xsd http://localhost:5005/validate
> <error>verbose error message</error> > <error>verbose error message</error>
``` ```
Example: Example:
``` ```shell
> curl -X POST -H "Content-Type: text/xml" -d @11044_17_DCC_v1.8.1_Au_with_error.xml http://localhost:5005/validate > curl -X POST -H "Content-Type: text/xml" -d @11044_17_DCC_v1.8.1_Au_with_error.xml http://localhost:5005/validate
> <error>failed decoding 'A' with XsdAtomicBuiltin(name='xs:double'): > <error>failed decoding 'A' with XsdAtomicBuiltin(name='xs:double'):
...@@ -78,7 +100,7 @@ Path: /{https://intranet.ptb.de/fileadmin/dokumente/intranet/abteilungen/abteilu ...@@ -78,7 +100,7 @@ Path: /{https://intranet.ptb.de/fileadmin/dokumente/intranet/abteilungen/abteilu
Returns the version of the validation server: Returns the version of the validation server:
``` ```shell
> curl http://localhost:5005/version > curl http://localhost:5005/version
> <version>0.2.0</version> > <version>0.2.0</version>
``` ```
...@@ -88,7 +110,7 @@ Returns the version of the validation server: ...@@ -88,7 +110,7 @@ Returns the version of the validation server:
Returns the version of the xsd-definition. The version is given at Returns the version of the xsd-definition. The version is given at
`xmlRoot.annotation.documentation` `xmlRoot.annotation.documentation`
``` ```shell
> curl http://localhost:5005/version_xsd > curl http://localhost:5005/version_xsd
<version>1.9.2</version> <version>1.9.2</version>
`` ``
...@@ -100,7 +122,7 @@ Updates the server; used by webhook (no security checks so far). ...@@ -100,7 +122,7 @@ Updates the server; used by webhook (no security checks so far).
### install daemon and start ### install daemon and start
``` ```shell
> cd /usr/local/share/xml-validation # working directory > cd /usr/local/share/xml-validation # working directory
> sudo nobody > sudo nobody
> git clone git@a75436.berlin.ptb.de:vaclab/xml-validation.git > git clone git@a75436.berlin.ptb.de:vaclab/xml-validation.git
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment