External XML validation

Updated Jul 01, 2026

The library includes support for validating generated XML against the TEI Episodic Profile Relax NG schema using external tools like jing. This provides an additional layer of assurance that emitted documents conform to the formal schema definition.

Local validation

Run the validation target to generate fixtures and validate them:

make validate-xml

This generates XML fixtures exercising different profile features (minimal documents, paragraphs, utterances, and comprehensive documents with citation declarations plus stand-off annotations), writes the embedded Relax NG schema, and validates each fixture using jing.

The validate-xml target requires jing to be installed. On Ubuntu/Debian:

sudo apt-get install jing

On macOS with Homebrew:

brew install jing

Continuous integration

CI automatically validates all XML fixtures against the Relax NG schema on every pull request. This ensures that changes to the data model or emitter do not produce invalid TEI documents. The CI workflow installs jing, generates fixtures using the generate-fixtures binary, and validates each fixture.

Fixture generation

The tei-xml crate provides a generate-fixtures binary that produces XML fixtures for validation. The fixtures exercise different aspects of the TEI Episodic Profile:

  • minimal: Header with title only, empty body
  • paragraphs: Body containing <p> elements with xml:id attributes
  • utterances: Profile with speakers, body with <u> elements referencing speakers via @who
  • div-list: Body containing <div type="..."> elements with nested <list>, <item>, and <label> children
  • guest-bios: Body containing <div type="guest-bios"> with nested guest-biography items whose @corresp values point at external reference revisions
  • comprehensive: All profile features combined (synopsis, speakers, languages, annotation systems, revision history, mixed body content including divisions)

Run the binary directly to generate fixtures to a custom location:

cargo run --package tei-xml --bin generate-fixtures -- /path/to/output

The generated XML includes the TEI namespace declaration required for schema validation.