A tutorial for learning how to customize schemas using the TEI ODD "chain" feature.

What is an ODD Chain

There are two approaches to ODD chains:

1. Inheritance (Vertical Chain)

Uses the source attribute to reference a parent ODD and inherit customizations.

TEI_all โ†’ Base ODD โ†’ Derived ODD โ†’ Further derivations...

2. Combination (Horizontal Chain)

Uses specGrp and specGrpRef to combine multiple ODDs.

Header ODD โ”€โ”€โ”ฌโ”€โ”€โ†’ Combined schema
Body ODD โ”€โ”€โ”€โ”€โ”˜

Directory Structure

tutorials/
โ”œโ”€โ”€ 01-inheritance/     # Inheritance examples
โ”‚   โ”œโ”€โ”€ base.odd        # Base ODD
โ”‚   โ””โ”€โ”€ derived.odd     # Derived ODD inheriting from base.odd
โ”œโ”€โ”€ 02-chain/           # Combination examples
โ”‚   โ”œโ”€โ”€ header-specs.odd    # Header-related customizations
โ”‚   โ”œโ”€โ”€ text-specs.odd      # Body text-related customizations
โ”‚   โ”œโ”€โ”€ main.odd            # Main ODD for integration
โ”‚   โ””โ”€โ”€ merge-specs.xsl     # XSLT for expanding specGrpRef
โ”œโ”€โ”€ output/             # Generated files
โ”‚   โ”œโ”€โ”€ base.rng            # Generated from 01 base ODD
โ”‚   โ”œโ”€โ”€ base.html           # HTML documentation for the above
โ”‚   โ”œโ”€โ”€ derived.rng         # Generated from 01 derived ODD
โ”‚   โ”œโ”€โ”€ derived.html        # HTML documentation for the above
โ”‚   โ”œโ”€โ”€ combined.rng        # Generated from 02 combined ODD
โ”‚   โ”œโ”€โ”€ combined.html       # HTML documentation for the above
โ”‚   โ””โ”€โ”€ intermediate/       # Intermediate files
โ”‚       โ”œโ”€โ”€ base.compiled.odd
โ”‚       โ”œโ”€โ”€ derived.compiled.odd
โ”‚       โ”œโ”€โ”€ combined.merged.odd
โ”‚       โ””โ”€โ”€ combined.compiled.odd
โ”œโ”€โ”€ build.sh            # Build script
โ””โ”€โ”€ README.md           # This file

Prerequisites

  • Saxon (XSLT 2.0 processor)
  • TEI Stylesheets (installed at ../scripts/Stylesheets)

Build Instructions

cd tutorials
./build.sh

Generated Files

Source ODDRNGHTML
01-inheritance/base.oddoutput/base.rngoutput/base.html
01-inheritance/derived.oddoutput/derived.rngoutput/derived.html
02-chain/main.odd (after combination)output/combined.rngoutput/combined.html

File Descriptions

01-inheritance (Inheritance)

base.odd

The base ODD containing minimal modules and basic customizations.

schemaSpec ident="baseSchema" start="TEI" source="tei:4.7.0">
  moduleRef key="tei"/>
  moduleRef key="header"/>
  moduleRef key="core"/>
  moduleRef key="textstructure"/>

schemaSpec>

derived.odd

A derived ODD that inherits from the TEI standard and adds further customizations.

schemaSpec ident="derivedSchema" start="TEI" source="tei:4.7.0">

  elementSpec ident="note" mode="delete"/>


  elementSpec ident="p" mode="change">
    attList>
      attDef ident="rend" mode="change">
        valList type="closed">
          valItem ident="indent"/>
          valItem ident="center"/>
        valList>
      attDef>
    attList>
  elementSpec>
schemaSpec>

02-chain (Combination)

header-specs.odd

Defines header-related customizations using specGrp.

specGrp xml:id="header-customizations">
  elementSpec ident="titleStmt" mode="change">

  elementSpec>
specGrp>

text-specs.odd

Defines body text-related customizations using specGrp.

specGrp xml:id="text-customizations">
  elementSpec ident="p" mode="change">

  elementSpec>
specGrp>

main.odd

Combines multiple ODDs using specGrpRef references.

schemaSpec ident="combinedSchema" start="TEI" source="tei:4.7.0">
  moduleRef key="tei"/>
  moduleRef key="header"/>
  moduleRef key="core"/>
  moduleRef key="textstructure"/>


  specGrpRef target="header-specs.odd#header-customizations"/>
  specGrpRef target="text-specs.odd#text-customizations"/>
schemaSpec>

Processing Flow

Inheritance

base.odd
    โ†“ odd2odd.xsl (compile)
intermediate/base.compiled.odd
    โ”œโ”€โ†’ odd2relax.xsl โ†’ base.rng
    โ””โ”€โ†’ odd2html.xsl  โ†’ base.html

derived.odd (source="tei:4.7.0")
    โ†“ odd2odd.xsl (compile + resolve inheritance)
intermediate/derived.compiled.odd
    โ”œโ”€โ†’ odd2relax.xsl โ†’ derived.rng
    โ””โ”€โ†’ odd2html.xsl  โ†’ derived.html

Combination

header-specs.odd โ”€โ”
                  โ”‚ merge-specs.xsl
text-specs.odd โ”€โ”€โ”€โ”ค (expand specGrpRef)
                  โ”‚
main.odd โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ†“
intermediate/combined.merged.odd
    โ†“ odd2odd.xsl
intermediate/combined.compiled.odd
    โ”œโ”€โ†’ odd2relax.xsl โ†’ combined.rng
    โ””โ”€โ†’ odd2html.xsl  โ†’ combined.html

XSLT Used

XSLTLocationRole
odd2odd.xslStylesheets/odds/ODD compilation (module expansion, inheritance resolution)
odd2relax.xslStylesheets/odds/RelaxNG schema generation
odd2html.xslStylesheets/odds/HTML documentation generation
merge-specs.xsl02-chain/specGrpRef expansion (custom)

References