Skip to content

About

Compile a TEI ODD's Processing Model into static edition rendering (CSS, XSLT, unified handlers and CETEIcean).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ODD Rendering Compiler

Companion code for the Code4Lib Journal article The TEI ODD as Static-Build Configuration: Compiling the Processing Model into Edition Rendering (Christian Forney, 2026).

A TEI ODD's Processing Model already says how each element should be presented. This project treats that declaration as build-time configuration: a compiler reads the ODD and generates the rendering artefacts — CSS, an XSLT stylesheet, unified/xast handlers, CETEIcean behaviours — which then render a TEI document into static HTML. No server, no runtime interpreter.

Define → generate → render. The ODD is the single source of truth (define); a build tool compiles its behaviours into rendering artefacts (generate); those artefacts turn TEI into a static edition (render).

The chain is implemented twice — in JavaScript and in XSLT — on purpose: the generate step is generic, not tied to one language. The unified handlers and the stylesheets of both XSLT generators render an equivalent static body, checked in CI (see docs/concept.md). docs/capabilities.md says what each target reads, implements and has executed.

⚠️ Note. This is an experimental implementation: it exists to illustrate the idea and reproduce the article, not as production code.

What's here

Directory What it is
compiler-js/ JavaScript implementation (generators, renderers, shared ODD parser, smoke tests)
compiler-xslt/ XSLT implementation (the same chain, built entirely in XSLT + Saxon)
runtime/ The behaviours both compilers copy into their output (pm.xsl, pm-runtime.mjs + xpath.mjs, ceteicean.js), and the scripts and styles of the interactive pages; see docs/concept.md
examples/ Shared inputs: the Simler edition's ODD with three excerpts, and the TEI's simplePrint exemplar; extensions/ holds an ODD extension, the nested page-break model

Quick start — JavaScript

Requires Node.js ≥ 20.

cd compiler-js
npm install
npm run demo      # compile the Simler ODD, then render → static + interactive HTML
npm run findings  # what the ODD does not foresee in the examples
npm run render:json && npm run coverage   # the ODD's decisions as data, read back against the corpus
npm test          # smoke tests, conformance fixtures, byte-identity gate

Generated artefacts and rendered pages land in compiler-js/output/. See compiler-js/README.md for every generator and renderer.

Your own ODD. One command does the whole pipeline:

node odd-render.mjs <odd> <tei...> [--out dir] [--tier name] [--reports] [--search]

It compiles edition.css and the handlers, renders every source with them, and tells you what it could not evaluate rather than refusing to build. For a publication build, add --strict: XPath outside the subset then fails the build instead of silently becoming a false predicate or an empty param. See compiler-js/README.md.

As a package or a library. npm install github:cforney/odd-rendering-compiler gives the npx odd-render command, and the compileOdd and renderDocument functions for a build that renders TEI itself (an Astro or Eleventy site, a rehype pipeline). See compiler-js/README.md.

Quick start — XSLT

Requires Java and Saxon HE 12. Point SAXON_HOME at your unpacked Saxon directory (download it from https://www.saxonica.com/download/java.xml), then:

cd compiler-xslt
bash build.sh     # default: the Simler edition
# or, on Windows:
./build.ps1

Outputs land in compiler-xslt/output/, one page per example for each rendering path. With Node present the build also emits a client-side SaxonJS demo (saxonjs/): the same edition.xsl, compiled to a SEF and run in the browser with an IXSL reading toggle — serve it over HTTP (e.g. npx http-server compiler-xslt/output). See compiler-xslt/README.md for details.

Demo — compare the rendering paths

Online demo: https://cforney.github.io/odd-rendering-compiler

A single static page frames the outputs both compilers build, so you can pick an example, switch rendering paths, toggle JavaScript, and see the generated artefact and its cost beside each result. Build both compilers, then assemble it:

cd compiler-js && npm run build:demo   # assembles demo/site/ from existing outputs
npx http-server ../demo/site           # then open the printed URL

See demo/README.md for the build steps and how to extend it.

Documentation

Examples, licensing, and credits

  • The code is licensed BSD-2-Clause (see LICENSE).
  • The example texts in examples/ are not covered by it: they keep their originating projects' terms. See examples/README.md for provenance and credits.

Acknowledgements

Several decisions follow e-editiones' Open Processing Model (OPM): XPath a target cannot run is compiled out and reported rather than failing the build; the render can be written as records in OPM's shape and read back as a coverage report; and an engine prefix on @output keeps engine-specific models apart. The Processing Model itself comes from TEI Simple and TEI Publisher. The islands tier follows the islands architecture and Astro's client:* directives.

How to cite

Archived on Zenodo: https://doi.org/10.5281/zenodo.24193138 (all versions; version 1.0.0: https://doi.org/10.5281/zenodo.24193139). See CITATION.cff.

About

Compile a TEI ODD's Processing Model into static edition rendering (CSS, XSLT, unified handlers and CETEIcean).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages