Section 5.1 RELAX-NG Schema¶
A schema is a set of patterns which describe how the elements of a language may be combined. The PreTeXt vocabulary is described by a RELAX-NG schema, which is included in the PreTeXt distribution. (RELAX-NG stands for “REgular LAnguage for XML Next Generation” and is pronounced “relaxing”.) In general terms, the schema tells you which elements are available, which attributes they may carry, and which other elements they may contain. You can then infer where you can place an element. The schema also indicates if an element is required or optional, if it may be repeated, or if it needs to appear in a prescribed order with other elements, and may limit attribute values.
Besides providing a concise formal description of the PreTeXt vocabulary, your XML source and the RELAX-NG schema can be provided to tools which will automatically validate your source against the formal definition. The best validators will provide accurate and helpful messages about errors in your source. Further, some editing tools will use a schema to provide context-sensitive assistance on available elements and attributes as you write, sparing you typographical errors, misplaced elements, and the need to frequently context-switch in order to consult reference material.
The schema does not tell you anything about how an element or attribute will behave. But hopefully there is not much ambiguity about the behavior of the content of a
<title> element nested within a
<chapter> element. You would not be surprised to see that content duplicated in the Table of Contents of a book. The purpose of this guide, and other documentation, is to help you understand what to expect. It is better to think of the schema as a contract between you and the developers of conversion tools. If your source conforms to the schema, then a conversion tool will produce reasonable output that conveys the structure and meaning of your writing. Twenty years from now, when GEFF is the dominant document format, a conversion of your source will preserve your meaning, while also taking advantage of the amazing features of GEFF. (GEFF stands for “Great Electronic Format of the Future”.)
In summary, the RELAX-NG schema
- is the formal specification of the PreTeXt vocabulary,
- is the key input to validation,
- can be incredibly helpful in the editing process, and
- provides guidance to implementors of conversions.
As such, we are very deliberate about changes, and hope over time to make changes only very rarely.