License: GPL 3+
‟A feather duster to reach the parts other schema languages cannot reach.”
—Rick Jelliffe
The :program:`schvalidator` script validates a given XML file with a ISO Schematron schema. Older Schematron versions are not supported.
XML file and Schematron schema is passed to lxml.isoschematron.Schematron
,
the result is collected and presented nicely.
To use the program without :command:`pip` and virtual environment, use the following command after cloning this repository:
$ PYTHONPATH=src python3 -m schvalidator -h
To install :program:`schvalidator`, use the following steps:
Clone this repository:
$ git clone http://github.com/openSUSE/schvalidator.git $ cd schvalidator
Create a Python 3 environment and activate it:
$ python3 -m venv .env $ source .env/bin/activate
Update the
pip
andsetuptools
modules:$ pip install -U pip setuptools
Install the package:
$ ./setup.py develop
If you need to install it from GitHub directly, use this URL:
git+https://github.com/openSUSE/schvalidator.git@develop
After the installation in your Python virtual environment, the script :program:`schvalidator` is available.
The script does the following steps:
- Collect all options and arguments through the docopts library.
- Check, if a Schematron schema and a XML file is passed to the script and they are available.
- If everything is ok, create a Schematron validator with the lxml library and validate the XML file.
- Get the result of the validation in an XML report with the root element
svrl:schematron-output
created by lxml. - Iterate through all
svrl:failed-assert
elements and output them accordingly. Take into account therole
attribute and map them to the logging level.
Done!
To contribute to this project, open issues or send us pull requests. Thanks!