acdh-xml-validator


Nameacdh-xml-validator JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryA python package to validate XML file using against custom schema and schematron files.
upload_time2025-07-21 11:52:15
maintainerNone
docs_urlNone
authorPeter Andorfer
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # acdh-xml-validator

A Python package for validating XML files against RelaxNG and Schematron schemas.
This module provides a Validator class that can validate XML documents using
both RelaxNG (.rng) and Schematron (.sch) schemas, particularly useful for
TEI (Text Encoding Initiative) XML documents.

## Installation

```shell
pip install acdh-xml-validator
```

or 

```shell
uv add acdh-xml-validator`
```


## Usage (CLI)

### RNG and Schematron
```shell
uv run validate-all --files "data/editions/*.xml" --rng "schemata/rng.rng" --schematron "schemata/schematron.sch"
```

### RNG
```shell
uv run validate-rng --files "data/editions/*.xml" --rng "schemata/rng.rng"
```

### SCHEMATRON
```shell
uv run validate-schematron --files "data/editions/*.xml" --schematron "schemata/schematron.sch"
```


## Usage (Python)

```python
import glob
from acdh_xml_validator import Validator


validator = Validator(
    path_to_rng="schemata/rng.rng",
    path_to_schematon="schemata/schematron.sch"
)

files = glob.glob("data/editions/*.xml")

for x in files:
    valid = validator.validate(x)
```

result:
```shell
test/xmls/L00003.xml is not valid according to test/schemata/rng.rng schema
  - test/xmls/L00003.xml:120:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMNAME: Expecting element idno, got rs
  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMNAME: Expecting element dateline, got signed
  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element signed there
  - test/xmls/L00003.xml:87:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element p there
  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element div has extra content: closer
  - test/xmls/L00003.xml:79:0:ERROR:RELAXNGV:RELAXNG_ERR_CONTENTVALID: Element text failed to validate content
test/xmls/L00107.xml is not valid according to test/schemata/tillich-schematron.sch
  - The @ref attribute for rs type @bible must start with a captial letter or with a number
  - The @ref attribute for rs type @bible must start with a captial letter or with a number
  - The @ref attribute for rs type @bible must start with a captial letter or with a number
```

## develop

install the package in editable mode

```shell
uv pip install -e .
uv run python
```

```python
>>> from acdh_xml_validator import hello
>>> hello()
'Hello you from acdh-xml-validator!'
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "acdh-xml-validator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Peter Andorfer",
    "author_email": "Peter Andorfer <p.andorfer@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/31/18/b5177de7f8b4b2d21ff9b408c40fd4bfefab16de25b44361187559831a35/acdh_xml_validator-1.1.0.tar.gz",
    "platform": null,
    "description": "# acdh-xml-validator\n\nA Python package for validating XML files against RelaxNG and Schematron schemas.\nThis module provides a Validator class that can validate XML documents using\nboth RelaxNG (.rng) and Schematron (.sch) schemas, particularly useful for\nTEI (Text Encoding Initiative) XML documents.\n\n## Installation\n\n```shell\npip install acdh-xml-validator\n```\n\nor \n\n```shell\nuv add acdh-xml-validator`\n```\n\n\n## Usage (CLI)\n\n### RNG and Schematron\n```shell\nuv run validate-all --files \"data/editions/*.xml\" --rng \"schemata/rng.rng\" --schematron \"schemata/schematron.sch\"\n```\n\n### RNG\n```shell\nuv run validate-rng --files \"data/editions/*.xml\" --rng \"schemata/rng.rng\"\n```\n\n### SCHEMATRON\n```shell\nuv run validate-schematron --files \"data/editions/*.xml\" --schematron \"schemata/schematron.sch\"\n```\n\n\n## Usage (Python)\n\n```python\nimport glob\nfrom acdh_xml_validator import Validator\n\n\nvalidator = Validator(\n    path_to_rng=\"schemata/rng.rng\",\n    path_to_schematon=\"schemata/schematron.sch\"\n)\n\nfiles = glob.glob(\"data/editions/*.xml\")\n\nfor x in files:\n    valid = validator.validate(x)\n```\n\nresult:\n```shell\ntest/xmls/L00003.xml is not valid according to test/schemata/rng.rng schema\n  - test/xmls/L00003.xml:120:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMNAME: Expecting element idno, got rs\n  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMNAME: Expecting element dateline, got signed\n  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element signed there\n  - test/xmls/L00003.xml:87:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element p there\n  - test/xmls/L00003.xml:119:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element div has extra content: closer\n  - test/xmls/L00003.xml:79:0:ERROR:RELAXNGV:RELAXNG_ERR_CONTENTVALID: Element text failed to validate content\ntest/xmls/L00107.xml is not valid according to test/schemata/tillich-schematron.sch\n  - The @ref attribute for rs type @bible must start with a captial letter or with a number\n  - The @ref attribute for rs type @bible must start with a captial letter or with a number\n  - The @ref attribute for rs type @bible must start with a captial letter or with a number\n```\n\n## develop\n\ninstall the package in editable mode\n\n```shell\nuv pip install -e .\nuv run python\n```\n\n```python\n>>> from acdh_xml_validator import hello\n>>> hello()\n'Hello you from acdh-xml-validator!'\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "A python package to validate XML file using against custom schema and schematron files.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/acdh-oeaw/acdh-xml-validator",
        "Issues": "https://github.com/acdh-oeaw/acdh-xml-validator/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4f072c83e008bfce0ba4871274a71c258a3b013950f2f0d0884df9f7ae6680e0",
                "md5": "ca802a17c979b1589edc009c78062476",
                "sha256": "290b8f1a0226ec8433f408b25e6ae28513507e65e2234d2e5b985a921b92d1e7"
            },
            "downloads": -1,
            "filename": "acdh_xml_validator-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca802a17c979b1589edc009c78062476",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5871,
            "upload_time": "2025-07-21T11:52:14",
            "upload_time_iso_8601": "2025-07-21T11:52:14.370291Z",
            "url": "https://files.pythonhosted.org/packages/4f/07/2c83e008bfce0ba4871274a71c258a3b013950f2f0d0884df9f7ae6680e0/acdh_xml_validator-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3118b5177de7f8b4b2d21ff9b408c40fd4bfefab16de25b44361187559831a35",
                "md5": "b71b47bc6e178b5cbf64172420419595",
                "sha256": "b4b901ff51d2975492142b0276d3145e58764baf536005bcd2857ea19bbdab8b"
            },
            "downloads": -1,
            "filename": "acdh_xml_validator-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b71b47bc6e178b5cbf64172420419595",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4067,
            "upload_time": "2025-07-21T11:52:15",
            "upload_time_iso_8601": "2025-07-21T11:52:15.425719Z",
            "url": "https://files.pythonhosted.org/packages/31/18/b5177de7f8b4b2d21ff9b408c40fd4bfefab16de25b44361187559831a35/acdh_xml_validator-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-21 11:52:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "acdh-oeaw",
    "github_project": "acdh-xml-validator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "acdh-xml-validator"
}
        
Elapsed time: 1.40684s