{"word_count": 425, "character_count": 4087}
Like any XML language, the TEI can be parsed with Schematron. Moreover, ODD supports natively the specification of Schematron rules, &#160;and the TEI specification itself (for instance here: https://github.com/TEIC/TEI/blob/dev/P5/Source/Specs/att.datable.w3c.xml ) contains embedded schematron rules. NB: This post doesn't aim to explain how the Schematron language works. To learn more about Schematron, see W. Piez and D. Lapeyre, Introduction to Schematron, Mulberry Technologies, Inc, Nov. 2008. However, to minimally understand the following, you should know that Schematron, an ISO specification, is an XML language, based on the extensive use of XPath, that makes assertions or reports on the presence or absence of specific patterns in XML documents.Schematron rules can be used to provide warnings without causing validation errors (i.e. "non-fatal errors"), or to add more qualitative rules to specific elements. For instance, one may want to set a character number limit for the content of a specific tag, or check the value of an attribute by means of a regular expression.ODD makes it convenient to specify such rules at the same level of the element specification, in an element &#60;constraintSpec&#62;, possibly present in &#60;attDef&#62;, &#60;classSpec&#62;, &#60;elementSpec&#62;, or &#60;schemaSpec&#62; (see the TEI guidelines for more details). Inside &#60;constraintSpec&#62;, the &#60;constraint&#62; element contains assertions in the Schematron language, as shown in the following example:&#60;elementSpec ident="TEI" mode="change"&#62;   &#60;constraintSpec ident="xmlid" scheme="schematron" type="SSK"&#62;      &#60;constraint&#62;         &#60;sch:rule context="tei:TEI"&#62;            &#60;sch:let name="fileName" value="tokenize(document-uri(/), '/')[last()]"/&#62;            &#60;sch:assert test="string(@xml:id)=substring-before($fileName, '.xml')" role="error"&#62;The xml:id of the TEI element should be equal to the name of the file,without the file extension. Currently the value of xml:id is "&#60;sch:value-of select="@xml:id"/&#62;" whilst the file name is "&#60;sch:value-of select="$fileName"/&#62;"&#60;/sch:assert&#62;         &#60;/sch:rule&#62;      &#60;/constraint&#62;﻿   &#60;/constraintSpec&#62;&#60;/elementSpec&#62;Two important caveats (thanks to Syd Bauman's XPath and Schematron for TEI Customization, https://www.wwp.northeastern.edu/outreach/seminars/_current/presentations/schematron/schematron_odd.xml):the element &#60;sch:rule&#62; is not mandatory. When missing (i.e., just bare sch:assert and sch:report elements), the context of the Schematron rule is the element or attribute that is being defined (&#60;elementSpec&#62; or &#60;attDef&#62;). In &#60;constraintSpec&#62;, you need to specify the tei: prefix for TEI elements (see example below).When a RELAX NG schema is generated from the ODD, the schematron rule will be embedded in the schema:&#60;define name="tei_TEI"&#62;   &#60;element name="TEI"&#62;   ...       &#60;pattern xmlns="http://purl.oclc.org/dsdl/schematron"               id="myTEI-TEI-xmlid-constraint-rule-10"&#62;         &#60;sch:rule xmlns="http://www.tei-c.org/ns/1.0"                   xmlns:sch="http://purl.oclc.org/dsdl/schematron"                   context="tei:TEI"&#62;            &#60;sch:let name="fileName" value="tokenize(document-uri(/), '/')[last()]"/&#62;            &#60;sch:assert test="string(@xml:id) = substring-before($fileName, '.xml')" role="error"&#62;The xml:id of the TEI element should be equal to the name of the file, without the file extension. Currently the value of xml:id is "&#60;sch:value-of select="@xml:id"/&#62;" whilst the file name is "&#60;sch:value-of select="$fileName"/&#62;"&#60;/sch:assert&#62;         &#60;/sch:rule&#62;      &#60;/pattern&#62;   ...   &#60;/element&#62;&#60;/define&#62;This embedded Schematron rule is checked in addition to the RELAX NG when performing file validation, as shown in the following images:See the full ODD example under:https://github.com/laurentromary/ODDtopics/blob/master/ODD%20examples/schematronODD.xml