Overview
I created an example workflow for generating TEI/XML from data prepared in Excel.
The following TEI/XML file is output. It supports page breaks using the pb tag, line IDs using the lb tag, multiple representations using choice/orig/reg tags, annotations using the note tag, and linking with IIIF images.
<?xml version="1.0" encoding="utf-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title/>
</titleStmt>
<publicationStmt>
<ab/>
</publicationStmt>
<sourceDesc>
<ab/>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<pb corresp="#page_22"/>
<ab>
<lb xml:id="page_22-b-1"/>
<seg>
いつれの御時にか女御更衣あまたさふらひ
<choice>
<orig>
給ける
<note corresp="#page_22-b-1-20" type="校異">
給けるーたまふ河
</note>
</orig>
<reg>
たまふ
</reg>
</choice>
なかにいとやむことなきゝは
</seg>
</ab>
</body>
</text>
<facsimile source="https://dl.ndl.go.jp/api/iiif/3437686/manifest.json">
<surface source="https://dl.ndl.go.jp/api/iiif/3437686/canvas/22" xml:id="page_22">
<label>
[22]
</label>
<zone lrx="1126" lry="1319" ulx="1044" uly="895" xml:id="page_22-b-1-20"/>
</surface>
<surface source="https://dl.ndl.go.jp/api/iiif/3437686/canvas/23" xml:id="page_23">
<label>
[23]
</label>
</surface>
</facsimile>
</TEI>
An example of visualizing the above TEI/XML data is shown below. The image, text (original), text (regularization), and annotations are displayed on the same screen.

Note that while the text from Koui Genji Monogatari is used here, the app element would be more appropriate for describing textual variants. Please understand this as sample data intended to explain the workflow.
Excel
The sample Excel data to prepare is available below. It has three sheets: image, text, and notes. Each is explained below.
https://github.com/nakamura196/tei_excel_tools/blob/main/demo/data/sample.xlsx?raw=true
“image” Sheet
This sheet describes information about the IIIF manifest file. Assign a unique ID for page_id.
“text” Sheet
In addition to the previously specified page_id, a new line_id is added. Enter the choice > orig text in text1 and the choice > reg text in text2.
| page_id | line_id | text1 | text2 |
|---|---|---|---|
| page_22 | page_22-b-1 | いつれの御時にか女御更衣あまたさふらひ給けるなかにいとやむことなきゝは | いつれの御時にか女御更衣あまたさふらひたまふなかにいとやむことなきゝは |
In the above example, the difference is between “給ける” and “たまふ”.
“notes” Sheet
This sheet describes annotation information.
In addition to the previously created page_id and line_id, a new note_id is added. pos specifies the character position in the line where the annotation should be placed. type and subtype are optional. text provides the annotation content. image is optional and specifies the IIIF image URL for the annotation. The method for creating this URL is described below.
| note_id | page_id | line_id | pos | type | subtype | text | image |
|---|---|---|---|---|---|---|---|
| page_22-b-1-20 | page_22 | page_22-b-1 | 22 | textual variant | 給けるーたまふ河 | https://dl.ndl.go.jp/api/iiif/3437686/R0000022/1044,895,82,424/full/0/default.jpg |
Converting to TEI/XML
The notebook for uploading Excel and downloading TEI/XML files is available here:
https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/tei_excel_tools.ipynb
Obtaining IIIF Image URLs for Annotations
Here is how to obtain the IIIF image URLs for annotations mentioned above. We use IIIF Curation Viewer created by the Center for Open Data in the Humanities (CODH).
Open the image containing the annotation by specifying manifest and pos in a URL like the following:
Next, click the button indicated by the red frame in the figure below to select the annotation area.

Then, when you click on the annotation area, the URL is displayed.

Paste this URL into the Excel file.
Summary
This is a use-case-specific method for creating TEI/XML files, but I hope it serves as a useful reference.