odd_schema¶
Load an ODD and compile it by following schemaSpec/@source (schema specs and
processing models). A TEI-targeting ODD (schemaSpec/@ns absent or the TEI
namespace) is merged onto cached p5subset.xml (TEI/@version selects a Vault
release). JATS / DocBook set another @ns and skip that base. use_guidelines
(opm odd document without SOURCE) documents TEI alone; it is not shipped in the wheel.
opm.odd_schema ¶
Load an ODD and compile it by following schemaSpec/@source.
An ODD may declare content models, processing models, or both. Compilation
walks the inheritance chain (parent ODDs first), then overlays local specs with
mode of add / change / delete / replace — including
model / modelGrp / modelSequence.
TEI-targeting ODDs (schemaSpec/@ns absent or the TEI namespace) are merged
onto cached p5subset.xml so moduleRef and content models resolve.
TEI/@version selects a Vault release; otherwise the latest release is
fetched. It is not shipped in the wheel. JATS / DocBook ODDs (@ns empty or
another vocabulary) are not merged onto TEI.
Specs and chapter prose are compiled separately and joined at the end: the
specs come from the moduleRef / @mode merge, the prose from the input
itself or, when the input is the schema being documented, from the downloaded
TEI Source/ Guidelines. The result is one tree carrying both.
SchemaError ¶
Bases: ValueError
The input is not an ODD / compiled spec document we can document.
CompiledSchema
dataclass
¶
CompiledSchema(
tree: _Element,
source_path: Path | None = None,
title: str = "",
ident: str = "",
warnings: list[str] = list(),
fetched_source: Path | None = None,
)
A schema ready to index: merged specs, plus chapter prose when there is any.
p5all_cache_path ¶
ensure_p5all ¶
ensure_p5all(
*,
fetch: bool = True,
url: str | None = None,
checksums_url: str | None = None,
) -> Path
Return a local p5all.xml, downloading it into the user cache if needed.
One file, one request. It carries the same specs as p5subset.xml plus
the Guidelines prose, so there is nothing else to fetch and no version to
resolve — the artifact tracks TEI's latest release.
Source code in src/opm/odd_schema.py
ensure_guideline_images ¶
ensure_guideline_images(
*,
fetch: bool = True,
url: str | None = None,
checksums_url: str | None = None,
) -> Path
Return the directory the Guidelines' figure URLs resolve against.
That is the directory of the cached p5all.xml, so Images/… sits
beside it just as it does beside the chapters in TEI's source. The figures
are downloaded on first use and unpacked whole or not at all.
Source code in src/opm/odd_schema.py
normalize_tei_version ¶
4.8.0 / 4.8 stay as Vault ids; anything else means latest.
Source code in src/opm/odd_schema.py
load_xml ¶
Parse path, or a directory of spec files, into one TEI tree.
Source code in src/opm/odd_schema.py
targets_tei ¶
True when schemaSpec/@ns is absent or the TEI namespace.
JATS (ns="") and DocBook (another namespace) are not TEI customizations.
Source code in src/opm/odd_schema.py
has_guidelines_chapters ¶
iter_guideline_chapters ¶
Yield top-level front/body/back divs used as Guidelines chapters.
Dedication / title-page verso and other typed front divs are included,
and so are the A–Z catalog stubs opm odd document puts in back matter:
they are its appendices.
Source code in src/opm/odd_schema.py
compile_schema ¶
compile_schema(
path: Path | str | None = None,
*,
use_guidelines: bool = False,
fetch: bool = True,
p5all_url: str | None = None,
) -> CompiledSchema
Load path and merge it along schemaSpec/@source.
- Parent ODDs are applied first, then the local file — the same order
parse_odduses for processing models. - A TEI-targeting ODD (
schemaSpec/@nsabsent or the TEI namespace) is merged onto the cached TEI artifact somoduleRefand content models resolve. It tracks TEI's latest release; an ODD pinning an olderTEI/@versionis compiled against the latest with a warning. JATS / DocBook set a different@nsand are left alone. use_guidelinesdocuments TEI alone.- A compiled document (Guidelines
p5.xml,p5subset.xml, a directory of Specs) with no further inheritance is returned as-is. - Chapter prose from the input is always kept. When the input is the
schema being documented (
use_guidelines, a Guidelinesp5.xml, a Specs directory) its chapters are published too. A customization merged onto TEI documents itself, so TEI's chapters stay out of its site.
Source code in src/opm/odd_schema.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
compiled_odd ¶
compiled_odd(compiled: CompiledSchema) -> _Element
compiled as a standalone ODD, for tools such as the TEI Stylesheets' odd2relax.
The merge leaves one schemaSpec with every spec in it and no moduleRef
to resolve, but only its @ident. This gives it back the other attributes of
the customization's schemaSpec: @start, @ns, @prefix and the like,
from the input ODD first and its parents after. @source is dropped, since
nothing is left to inherit from.
Source code in src/opm/odd_schema.py
chapters_have_prose ¶
True when guideline chapters contain prose outside specification elements.
p5subset.xml keeps the division/heading skeleton (and inlined specs)
but strips ordinary chapter paragraphs — those chapters must not be treated
as a full Guidelines document.
Source code in src/opm/odd_schema.py
chapter_has_prose ¶
True when div has ordinary prose, not only inlined specs.
Front matter such as the title-page verso is often a list with no
p; those still belong on the site.
Source code in src/opm/odd_schema.py
schema_ident ¶
schemaSpec/@ident, else the source file stem, else schema.