Catalog PyPI
PACKAGE EXPLORERView in registry

acdh-xml-validator

PyPI

A python package to validate XML file using against custom schema and schematron files.

Versions collected1
Direct dependencies3From release 1.1.0
Last observed20 Oct, 18:05 UTC

README

Version 1.1.0 documentation

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

pip install acdh-xml-validator

or

uv add acdh-xml-validator`

Usage (CLI)

RNG and Schematron

uv run validate-all --files "data/editions/*.xml" --rng "schemata/rng.rng" --schematron "schemata/schematron.sch"

RNG

uv run validate-rng --files "data/editions/*.xml" --rng "schemata/rng.rng"

SCHEMATRON

uv run validate-schematron --files "data/editions/*.xml" --schematron "schemata/schematron.sch"

Usage (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:

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

uv pip install -e .
uv run python
>>> from acdh_xml_validator import hello
>>> hello()
'Hello you from acdh-xml-validator!'

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.1.021 Jul 20253

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
acdh-oeaw/acdh-xml-validator

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:05 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:074fb50b665e99b35dea501218440acdd7079cc592e3f11e88cf2763b3d6c3fc