Overview

This is an investigation record on how to customize LEAF Writer.

https://gitlab.com/calincs/cwrc/leaf-writer/leaf-writer

This time, it is a memo on how to customize schemas. The goal is to display Japanese translations and other customizations as shown below.

Below is the display before customization. Based on the following schema, many elements are displayed with English descriptions.

https://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng

Method

Specify the schema file as follows.

https://github.com/kouigenjimonogatari/kouigenjimonogatari.github.io/blob/master/xml/lw/01.xml

Specifically:

<?xml-modelhref="https://kouigenjimonogatari.github.io/lw/tei_genji.rng"type="application/xml"schematypens="http://relaxng.org/ns/structure/1.0"?>

LEAF Writer reads this schema file and uses it for validation and presenting available elements.

This is not a feature specific to LEAF Writer; general XML editors such as Oxygen XML Editor often work in the same way.

(Reference) Customizing LEAF Writer

As described above, LEAF Writer references the schema specified in the loaded XML file, resulting in a loosely coupled architecture between the editor and schema.

However, when referencing a schema other than those pre-defined in LEAF Writer, the following dialog is displayed, and you need to inform LEAF Writer about your custom schema by clicking the “ADD SCHEMA” button.

If you perform the registration process above, there is no problem, but if you want to add a definition to LEAF Writer in advance, you need to customize LEAF Writer.

Specifically, by making the following modifications, the specified schema and CSS could be pre-registered in LEAF Writer.

https://gitlab.com/nakamura196/leaf-writer/-/commit/dc5108978bc3013a80965913d74e729daf6941f2

The following was added to the packages/cwrc-leafwriter/src/config/schemas.ts file.

{},inmrcdaans:mpgsep::':itn[[e'g''iT:hhGEtteI'ttntppjGessiei::'n'/,j,/ikk'oo,uuiiggeennjjiimmoonnooggaattaarrii..ggiitthhuubb..iio/llww//tteeii__ggeennjjii..rcnsgs'']],,

With this, the specified schema is pre-registered in LEAF Writer, and the additional configuration above is no longer needed when referencing the same schema.

Summary

We hope this serves as a useful reference for handling schemas in TEI and tools such as LEAF Writer.