<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <title>ISO Schematron rules</title>
   <!-- This file generated 2025-08-28T16:49:05Z by 'extract-isosch.xsl'. -->
   <!-- ********************* -->
   <!-- namespaces, declared: -->
   <!-- ********************* -->
   <ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
   <ns prefix="xs" uri="http://www.w3.org/2001/XMLSchema"/>
   <ns prefix="rng" uri="http://relaxng.org/ns/structure/1.0"/>
   <ns prefix="rna" uri="http://relaxng.org/ns/compatibility/annotations/1.0"/>
   <ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/>
   <ns prefix="sch1x" uri="http://www.ascc.net/xml/schematron"/>
   <ns prefix="teix" uri="http://www.tei-c.org/ns/Examples"/>
   <!-- ********************* -->
   <!-- namespaces, implicit: -->
   <!-- ********************* -->
   <ns prefix="esp-d2e92258" uri="http://www.example.org/cannot/really/use/XInclude"/>
   <ns prefix="esp-d2e92315" uri="http://www.example.org/cannot/really/use/XInclude"/>
   <!-- ******************************************************** -->
   <!-- constraints in en, und, mul, zxx, of which there are 116 -->
   <!-- ******************************************************** -->
   <pattern id="schematron-constraint-CMC_generatedBy_within_post-1">
      <rule context="tei:*[@generatedBy]">
         <assert test="ancestor-or-self::tei:post">The @generatedBy attribute is for use within a &lt;post&gt; element.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-att-datable-w3c-when-2">
      <rule context="tei:*[@when]">
         <report test="@notBefore|@notAfter|@from|@to" role="nonfatal">The @when attribute cannot be used with any other att.datable.w3c attributes.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-att-datable-w3c-from-3">
      <rule context="tei:*[@from]">
         <report test="@notBefore" role="nonfatal">The @from and @notBefore attributes cannot be used together.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-att-datable-w3c-to-4">
      <rule context="tei:*[@to]">
         <report test="@notAfter" role="nonfatal">The @to and @notAfter attributes cannot be used together.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-only_1_ODD_source-5">
      <rule context="tei:*[@source]">
         <let name="srcs" value="tokenize( normalize-space(@source),' ')"/>
         <report test="(   self::tei:classRef                                 | self::tei:dataRef                                 | self::tei:elementRef                                 | self::tei:macroRef                                 | self::tei:moduleRef                                 | self::tei:schemaSpec )                                   and                                   $srcs[2]"> When used on a schema description element (like <value-of select="name(.)"/>), the @source attribute should have only 1 value. (This one has <value-of select="count($srcs)"/>.)</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-att-measurement-unitRef-6">
      <rule context="tei:*[@unitRef]">
         <report test="@unit" role="info">The @unit attribute may be unnecessary when @unitRef is present.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-targetLang-7">
      <rule context="tei:*[not(self::tei:schemaSpec)][@targetLang]">
         <assert test="@target">@targetLang should only be used on <name/> if @target is specified.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-spanTo-points-to-following-8">
      <rule context="tei:*[ starts-with( @spanTo, '#') ]">
         <assert test="id( substring( @spanTo, 2 ) ) &gt;&gt; ."> The element indicated by @spanTo (<value-of select="@spanTo"/>) must follow the current <name/> element</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-schemeVersionRequiresScheme-9">
      <rule context="tei:*[@schemeVersion]">
         <assert test="@scheme and not(@scheme = 'free')"> @schemeVersion can only be used if @scheme is specified.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-subtypeTyped-10">
      <rule context="tei:*[@subtype]">
         <assert test="@type">The <name/> element should not be categorized in detail with @subtype unless also categorized in general with @type</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-not_in_future-11">
      <rule context="*[@versionDate]">
         <let name="tomorrow" value="current-date() + 'P1D' cast as xs:dayTimeDuration"/>
         <assert test="@versionDate cast as xs:date le $tomorrow">The date of a translation should not be in the future.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-calendar_attr_on_empty_element-12">
      <rule context="tei:*[@calendar]">
         <assert test="string-length( normalize-space(.) ) gt 0"> @calendar indicates one or more systems or calendars to which the date represented by the content of this element belongs, but this <name/> element has no textual content.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-p-in-ab-or-p-13">
      <rule context="tei:p">
         <report test="(ancestor::tei:ab or ancestor::tei:p) and                        not( ancestor::tei:floatingText                           | parent::tei:exemplum                           | parent::tei:item                           | parent::tei:note                           | parent::tei:q                           | parent::tei:quote                           | parent::tei:remarks                           | parent::tei:said                           | parent::tei:sp                           | parent::tei:stage                           | parent::tei:cell                           | parent::tei:figure )"> Abstract model violation: Paragraphs may not occur inside other paragraphs or ab elements.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-p-in-l-14">
      <rule context="tei:l//tei:p">
         <assert test="ancestor::tei:floatingText | parent::tei:figure | parent::tei:note"> Abstract model violation: Metrical lines may not contain higher-level structural elements such as div, p, or ab, unless p is a child of figure or note, or is a descendant of floatingText.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-deprecationInfo-only-in-deprecated-15">
      <rule context="tei:desc[ @type eq 'deprecationInfo']">
         <assert test="../@validUntil">Information about a deprecation should only be present in a specification element that is being deprecated: that is, only an element that has a @validUntil attribute should have a child &lt;desc type="deprecationInfo"&gt;.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-rt-target-not-span-16">
      <rule context="tei:rt/@target">
         <report test="../@from | ../@to">When target= is present, neither from= nor to= should be.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-rt-from-17">
      <rule context="tei:rt/@from">
         <assert test="../@to">When from= is present, the to= attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-rt-to-18">
      <rule context="tei:rt/@to">
         <assert test="../@from">When to= is present, the from= attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-ptrAtts-19">
      <rule context="tei:ptr">
         <report test="@target and @cRef">Only one of the attributes @target and @cRef may be supplied on <name/>.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-refAtts-20">
      <rule context="tei:ref">
         <report test="@target and @cRef">Only one of the attributes @target and @cRef may be supplied on <name/>.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-gloss-list-must-have-labels-21">
      <rule context="tei:list[@type='gloss']">
         <assert test="tei:label">The content of a "gloss" list should include a sequence of one or more pairs of a label element followed by an item element</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-targetorcontent1-22">
      <rule context="tei:relatedItem">
         <report test="@target and count( child::* ) &gt; 0">If the @target attribute on <name/> is used, the relatedItem element must be empty</report>
         <assert test="@target or child::*">A relatedItem element should have either a @target attribute or a child element to indicate the related bibliographic item</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-l-in-l-23">
      <rule context="tei:l">
         <report test="ancestor::tei:l[not(.//tei:note//tei:l[. = current()])]">Abstract model violation: Lines may not contain lines or lg elements.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-atleast1oflggapl-24">
      <rule context="tei:lg">
         <assert test="count(descendant::tei:lg|descendant::tei:l|descendant::tei:gap) &gt; 0">An lg element must contain at least one child l, lg, or gap element.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-lg-in-l-25">
      <rule context="tei:lg">
         <report test="ancestor::tei:l[not(.//tei:note//tei:lg[. = current()])]">Abstract model violation: Lines may not contain line groups.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-quotationContents-26">
      <rule context="tei:quotation">
         <report test="not( @marks )  and  not( tei:p )"> On <name/>, either the @marks attribute should be used, or a paragraph of description provided</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-citestructure-outer-match-27">
      <rule context="tei:citeStructure[not(parent::tei:citeStructure)]">
         <assert test="starts-with(@match,'/')">An XPath in @match on the outer <name/> must start with '/'.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-citestructure-inner-match-28">
      <rule context="tei:citeStructure[parent::tei:citeStructure]">
         <assert test="not(starts-with(@match,'/'))">An XPath in @match must not start with '/' except on the outer <name/>.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-ref-or-key-or-name-29">
      <rule context="tei:relation">
         <assert test="@ref or @key or @name">One of the attributes @name, @ref or @key must be supplied</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-active-mutual-30">
      <rule context="tei:relation">
         <report test="@active and @mutual">Only one of the attributes @active and @mutual may be supplied</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-active-passive-31">
      <rule context="tei:relation">
         <report test="@passive and not(@active)">the attribute @passive may be supplied only if the attribute @active is supplied</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-must-have-attglobal-32">
      <rule context="tei:elementSpec[not(@mode)]">
         <assert test="tei:classes/tei:memberOf[@key='att.global']">Error: TEI element <value-of select="@ident"/> must be member of att.global class</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-div-in-l-33">
      <rule context="tei:l//tei:div">
         <assert test="ancestor::tei:floatingText"> Abstract model violation: Metrical lines may not contain higher-level structural elements such as div, unless div is a descendant of floatingText.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-div-in-ab-or-p-34">
      <rule context="tei:div">
         <report test="(ancestor::tei:p or ancestor::tei:ab) and not(ancestor::tei:floatingText)"> Abstract model violation: p and ab may not contain higher-level structural elements such as div, unless div is a descendant of floatingText.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-require-translatability-35">
      <rule context="  tei:elementSpec/tei:desc                                  | tei:elementSpec/tei:gloss                                  | tei:elementSpec/tei:remarks                                  | tei:classSpec/tei:desc                                  | tei:classSpec/tei:gloss                                  | tei:classSpec/tei:remarks                                  | tei:macroSpec/tei:desc                                  | tei:macroSpec/tei:gloss                                  | tei:macroSpec/tei:remarks                                  | tei:attDef/tei:desc                                  | tei:attDef/tei:gloss                                  | tei:attDef/tei:remarks                                  | tei:valItem/tei:desc                                  | tei:valItem/tei:gloss                                  | tei:valItem/tei:remarks                                  | tei:moduleSpec/tei:desc                                  | tei:moduleSpec/tei:gloss                                  | tei:moduleSpec/tei:remarks                                  ">
         <assert test="@xml:lang  and  @versionDate"> Error: both the versionDate and xml:lang attributes on "<name/>" are required when it is a child of "<value-of select="local-name(..)"/>".</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-en-first-36">
      <rule context="  tei:elementSpec/tei:desc[1]                                  | tei:elementSpec/tei:gloss[1]                                  | tei:elementSpec/tei:remarks[1]                                  | tei:classSpec/tei:desc[1]                                  | tei:classSpec/tei:gloss[1]                                  | tei:classSpec/tei:remarks[1]                                  | tei:macroSpec/tei:desc[1]                                  | tei:macroSpec/tei:gloss[1]                                  | tei:macroSpec/tei:remarks[1]                                  | tei:attDef/tei:desc[1]                                  | tei:attDef/tei:gloss[1]                                  | tei:attDef/tei:remarks[1]                                  | tei:valItem/tei:desc[1]                                  | tei:valItem/tei:gloss[1]                                  | tei:valItem/tei:remarks[1]                                  | tei:moduleSpec/tei:desc[1]                                  | tei:moduleSpec/tei:gloss[1]                                  | tei:moduleSpec/tei:remarks[1]                                   ">
         <assert test="lang('en')">The first <value-of select="name(.)"/> child of a <value-of select="name(..)"/> should have an @xml:lang that indicates it is in English.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-only-one-each-lang-37">
      <rule context="  tei:elementSpec/tei:desc[ position() &gt; 1 ]                                  | tei:elementSpec/tei:gloss[ position() &gt; 1 ]                                  | tei:elementSpec/tei:remarks[ position() &gt; 1 ]                                  | tei:classSpec/tei:desc[ position() &gt; 1 ]                                  | tei:classSpec/tei:gloss[ position() &gt; 1 ]                                  | tei:classSpec/tei:remarks[ position() &gt; 1 ]                                  | tei:macroSpec/tei:desc[ position() &gt; 1 ]                                  | tei:macroSpec/tei:gloss[ position() &gt; 1 ]                                  | tei:macroSpec/tei:remarks[ position() &gt; 1 ]                                  | tei:attDef/tei:desc[ position() &gt; 1 ]                                  | tei:attDef/tei:gloss[ position() &gt; 1 ]                                  | tei:attDef/tei:remarks[ position() &gt; 1 ]                                  | tei:valItem/tei:desc[ position() &gt; 1 ]                                  | tei:valItem/tei:gloss[ position() &gt; 1 ]                                  | tei:valItem/tei:remarks[ position() &gt; 1 ]                                  | tei:moduleSpec/tei:desc[ position() &gt; 1 ]                                  | tei:moduleSpec/tei:gloss[ position() &gt; 1 ]                                  | tei:moduleSpec/tei:remarks[ position() &gt; 1 ]                                   ">
         <let name="myGI" value="name(.)"/>
         <let name="myType" value="@type"/>
         <let name="hasType" value="if (@type) then true() else false()"/>
         <let name="lang" value="normalize-space( @xml:lang )"/>
         <report test="preceding-sibling::*[ name(.) eq $myGI ][(not(@type) and not($hasType)) or @type eq $myType][ normalize-space( @xml:lang) eq $lang ]">The sibling <value-of select="$myGI"/> children of a <value-of select="name(..)"/> should each have a different @xml:lang; this one duplicates the "<value-of select="$lang"/>" of a preceding sibling.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-all-sibling-parent-desc-38">
      <rule context="*[tei:desc[@versionDate]]">
         <report role="nonfatal" test="count( tei:desc )                                                   ne                                                   count( tei:desc[@versionDate] )                                                   "> Error: sibling 'desc' elements with and without @versionDate.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-all-sibling-parent-gloss-39">
      <rule context="*[tei:gloss[@versionDate]]">
         <report role="nonfatal" test="count( tei:gloss )                                                   ne                                                   count( tei:gloss[@versionDate] )                                                   "> Error: sibling 'gloss' elements with and without @versionDate.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-all-sibling-parent-remarks-40">
      <rule context="*[tei:remarks[@versionDate]]">
         <report role="nonfatal" test="count( tei:remarks )                                                   ne                                                   count( tei:remarks[@versionDate] )                                                   "> Error: sibling 'remarks' elements with and without @versionDate.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-all-sibling-parent-valDesc-41">
      <rule context="*[tei:valDesc[@versionDate]]">
         <report role="nonfatal" test="                                                   count( tei:valDesc )                                                   ne                                                   count( tei:valDesc[@versionDate] )                                                   "> Error: sibling 'valDesc' elements with and without @versionDate.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-MINandMAXoccurs-42">
      <rule context="tei:*[ @minOccurs and @maxOccurs ]">
         <let name="min" value="@minOccurs cast as xs:integer"/>
         <let name="max" value="if ( normalize-space( @maxOccurs ) eq 'unbounded') then -1 else @maxOccurs cast as xs:integer"/>
         <assert test="$max eq -1 or $max ge $min">@maxOccurs should be greater than or equal to @minOccurs</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-MINandMAXoccurs-43">
      <rule context="tei:*[ @minOccurs and not( @maxOccurs ) ]">
         <assert test="@minOccurs cast as xs:integer lt 2">When @maxOccurs is not specified, @minOccurs must be 0 or 1</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-spec-in-module-44">
      <rule context="tei:elementSpec[@module]|tei:classSpec[@module]|tei:macroSpec[@module]">
         <assert test="(not(ancestor::tei:schemaSpec | ancestor::tei:TEI | ancestor::tei:teiCorpus)) or (not(@module) or (not(//tei:moduleSpec) and not(//tei:moduleRef)) or (//tei:moduleSpec[@ident = current()/@module]) or (//tei:moduleRef[@key = current()/@module]))"> Specification <value-of select="@ident"/>: the value of the module attribute ("<value-of select="@module"/>") should correspond to an existing module, via a moduleSpec or moduleRef</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-deprecation-two-month-warning-45">
      <rule context="tei:*[@validUntil]">
         <let name="advance_warning_period" value="current-date() + xs:dayTimeDuration('P60D')"/>
         <let name="me_phrase" value="if (@ident) then concat('The ', @ident ) else concat('This ', local-name(.), ' of ', ancestor::tei:*[@ident][1]/@ident )"/>
         <assert test="@validUntil cast as xs:date ge current-date()">
            <value-of select="concat( $me_phrase, ' construct is outdated (as of ', @validUntil, '); ODD processors may ignore it, and its use is no longer supported' )"/>
         </assert>
         <assert role="warning" test="@validUntil cast as xs:date ge $advance_warning_period">
            <value-of select="concat( $me_phrase, ' construct becomes outdated on ', @validUntil )"/>
         </assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-deprecation-should-be-explained-46">
      <rule context="tei:*[@validUntil][ not( self::tei:valDesc | self::tei:valList | self::tei:defaultVal | self::tei:remarks )]">
         <assert test="child::tei:desc[ @type eq 'deprecationInfo']"> A deprecated construct should include, whenever possible, an explanation, but this <value-of select="name(.)"/> does not have a child &lt;desc type="deprecationInfo"&gt;</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-no_leading_nor_trailing_new_newlines-47">
      <rule context="tei:eg">
         <report test="matches( string(.), '&#xA;\s*$')">trailing newline not allowed</report>
         <report test="matches( string(.), '^\s*&#xA;')">leading newline not allowed</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-only_sensible_attrs-32">
      <rule context="tei:elementRef[ parent::tei:schemaSpec | parent::tei:specGrp ]">
         <report test="@minOccurs | @maxOccurs" role="error">An element reference is not repeatable when part of a schema specification (and thus this &lt;elementRef&gt; should not have @minOccurs or @maxOccurs).</report>
      </rule>
      <rule context="tei:content//tei:elementRef">
         <report test="@source" role="error">An element reference within a content model must refer to a locally defined element specification (and thus this &lt;elementRef&gt; should not have @source).</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-modref-50">
      <rule context="tei:moduleRef">
         <report test="* and @key"> Child elements of <name/> are only allowed when an external module is being loaded</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-not-same-prefix-51">
      <rule context="tei:moduleRef">
         <report test="//*[ not( generate-id(.) eq generate-id( current() ) ) ]/@prefix = @prefix">The prefix attribute of <name/> should not match that of any other element (it would defeat the purpose)</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-not-except-and-include-52">
      <rule context="tei:moduleRef">
         <report test="@except and @include">It is an error to supply both the @include and @except attributes</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-child-constraint-based-on-mode-53">
      <rule context="tei:elementSpec[ @mode eq 'delete' ]">
         <report test="child::*">This elementSpec element has a mode= of "delete" even though it has child elements. Change the mode= to "add", "change", or "replace", or remove the child elements.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-child-constraint-based-on-mode-54">
      <rule context="tei:elementSpec[ @mode = ('add','change','replace') ]">
         <assert test="child::* | (@* except (@mode, @ident))">This elementSpec element has a mode= of "<value-of select="@mode"/>", but does not have any child elements or schema-changing attributes. Specify child elements, use validUntil=, predeclare=, ns=, or prefix=, or change the mode= to "delete".</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-no_elements_in_data_content-55">
      <rule role="warn" context="tei:dataSpec/tei:content">
         <report test=".//tei:anyElement | .//tei:classRef | .//tei:elementRef"> A datatype specification should not refer to an element or a class.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-only-one-remark-per-lang-56">
      <rule context="tei:remarks[@xml:lang]">
         <let name="langVal" value="@xml:lang"/>
         <assert test="not(following-sibling::tei:remarks[@xml:lang=$langVal])"> Error: There should only be one <value-of select="@ident"/> element per language. Merge the contents of multiple <value-of select="@ident"/> elements using separate p elements.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-TagDocsNestinglistRef-57">
      <rule context="( tei:classSpec | tei:dataSpec | tei:elementSpec | tei:macroSpec | tei:moduleSpec | tei:schemaSpec | tei:specGrp )/tei:listRef">
         <report test="tei:listRef">In the context of tagset documentation, the listRef element must not self-nest.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-TagDocslistRefChildren-58">
      <rule context="( tei:classSpec | tei:dataSpec | tei:elementSpec | tei:macroSpec | tei:moduleSpec | tei:schemaSpec | tei:specGrp )/tei:listRef/tei:ptr | ( tei:classSpec | tei:dataSpec | tei:elementSpec | tei:macroSpec | tei:moduleSpec | tei:schemaSpec | tei:specGrp )/tei:listRef/tei:ref">
         <assert test="@target and not( matches( @target,'\s') )">In the context of tagset documentation, each ptr or ref element inside a listRef must have a target attribute with only 1 pointer as its value.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-order_of_membership-59">
      <rule context="tei:classes">
         <let name="keys_as_specified" value="tei:memberOf/@key"/>
         <let name="keys_in_order" value="if ( $keys_as_specified = 'att.global' )                                 then ( 'att.global', sort( $keys_as_specified )[. ne 'att.global'] )                                 else sort( $keys_as_specified )"/>
         <assert test="string-join( $keys_as_specified ) eq string-join( $keys_in_order )"> class membership (in this case of <value-of select="ancestor::*[@ident][1]/@ident"/>) should be specified in sorted order, except att.global goes first.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-restricted-altIdent-placement-60">
      <rule context="tei:altIdent">
         <assert test="parent::tei:elementSpec|parent::tei:attDef|parent::tei:valItem">The &lt;altIdent&gt; element should only be used as a child of &lt;elementSpec&gt;, &lt;attDef&gt;, or &lt;valItem&gt;.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-no_dup_default_models-61">
      <rule context="tei:model[ not( parent::tei:modelSequence ) ][ not( @predicate ) ]">
         <let name="output" value="normalize-space( @output )"/>
         <report test="following-sibling::tei:model [ not( @predicate )] [ normalize-space( @output ) eq $output ]"> There are 2 (or more) 'model' elements in this '<value-of select="local-name(..)"/>' that have no predicate, but are targeted to the same output ("<value-of select="( $output, parent::modelGrp/@output, 'all')[1]"/>")</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-no_dup_models-62">
      <rule context="tei:model[ not( parent::tei:modelSequence ) ][ @predicate ]">
         <let name="predicate" value="normalize-space( @predicate )"/>
         <let name="output" value="normalize-space( @output )"/>
         <report test="following-sibling::tei:model [ normalize-space( @predicate ) eq $predicate ] [ normalize-space( @output ) eq $output ]"> There are 2 (or more) 'model' elements in this '<value-of select="local-name(..)"/>' that have the same predicate, and are targeted to the same output ("<value-of select="( $output, parent::modelGrp/@output, 'all')[1]"/>")</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-no_outputs_nor_predicates_4_my_kids-63">
      <rule context="tei:modelSequence">
         <report test="tei:model[@output]" role="warning">The 'model' children of a 'modelSequence' element inherit the @output attribute of the parent 'modelSequence', and thus should not have their own</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-sequencechilden-64">
      <rule context="tei:sequence">
         <assert test="count(*) gt 1">The sequence element must have at least two child elements</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-alternatechilden-65">
      <rule context="tei:alternate">
         <assert test="count(*) gt 1">The alternate element must have at least two child elements</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-one-constraintDecl-per-scheme-66">
      <rule context="/*[ count( //tei:constraintDecl ) gt 1 ]">
         <let name="schemes" value="//tei:constraintDecl[ not(ancestor::*[local-name(.) eq 'egXML'] ) ]/@scheme"/>
         <let name="disctinct_schemes" value="distinct-values( $schemes )"/>
         <assert test="count( $schemes ) eq count( $disctinct_schemes )"> Each &lt;constraintDecl&gt; element should have a @scheme attribute that is distinct from that of all the other &lt;constraintDecl&gt;s.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-empty-based-on-mode-68">
      <rule context="tei:constraintSpec[ @mode eq 'delete']">
         <report test="child::*">This constraintSpec element has a mode= of "delete" even though it has child elements. Change the mode= to "add", "change", or "replace", or remove the child elements.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-empty-based-on-mode-69">
      <rule context="tei:constraintSpec[ @mode eq 'change']">
         <assert test="child::*">This constraintSpec element has a mode= of "change", but does not have any child elements. Specify child elements, or change the mode= to "delete".</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-empty-based-on-mode-70">
      <rule context="tei:constraintSpec[ @mode = ('add','replace') ]">
         <assert test="child::tei:constraint">This constraintSpec element has a mode= of "<value-of select="@mode"/>", but does not have a child 'constraint' element. Use a child 'constraint' element or change the mode= to "delete" or "change".</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-sch_no_more-71">
      <rule context="tei:constraintSpec">
         <report test="tei:constraint/sch1x:* and @scheme = ('isoschematron','schematron')">Rules in the Schematron 1.* language must be inside a constraintSpec with a value other than 'schematron' or 'isoschematron' on the scheme attribute</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-isosch-72">
      <rule context="tei:constraintSpec[ @mode = ('add','replace') or not( @mode ) ]">
         <report test="tei:constraint/sch:* and not( @scheme eq 'schematron')">Rules in the ISO Schematron language must be inside a constraintSpec with the value 'schematron' on the scheme attribute</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-context-required-73">
      <rule context="(tei:constraintSpec|tei:constraintDecl)[ @scheme eq 'schematron'][ .//sch:assert | .//sch:report ]">
         <let name="assertsHaveContext" value="for $a in .//sch:assert return exists( $a/ancestor::sch:rule/@context )"/>
         <let name="reportsHaveContext" value="for $r in .//sch:report return exists( $r/ancestor::sch:rule/@context )"/>
         <report test="( $assertsHaveContext, $reportsHaveContext ) = false()">An &lt;sch:assert&gt; or &lt;sch:report&gt; element must be a descendant of an &lt;sch:rule&gt; that has a @context; one or more inside this <value-of select="local-name(.)"/> are not.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-unique-constraintSpec-ident-74">
      <rule context="tei:constraintSpec[ @mode eq 'add' or not( @mode ) ]">
         <let name="myIdent" value="normalize-space(@ident)"/>
         <report test="preceding::tei:constraintSpec[ normalize-space(@ident) eq $myIdent ]"> The @ident of 'constraintSpec' should be unique; this one (<value-of select="$myIdent"/>) is the same as that of a previous 'constraintSpec'.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-usage_based_on_mode-75">
      <rule context="tei:constraintSpec[ @mode = ('add','replace')  or  not( @mode ) ]">
         <assert test="@scheme">The @scheme attribute of &lt;constraintSpec&gt; is required when the @mode is <value-of select="if (@mode) then concat('&#34;',@mode,'&#34;') else 'not specified'"/> (here on "<value-of select="@ident"/>")</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-usage_based_on_mode-76">
      <rule context="tei:constraintSpec[ @mode = ('add','replace')  or  not( @mode ) ]">
         <assert test="@scheme">The @scheme attribute of &lt;constraintSpec&gt; is required when the @mode is <value-of select="if (@mode) then concat('&#34;',@mode,'&#34;') else 'not specified'"/> (here on "<value-of select="@ident"/>")</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-attDefContents-79">
      <rule context="tei:attDef">
         <assert test="ancestor::teix:egXML[ @valid eq 'feasible']                        or @mode eq 'change'                        or @mode eq 'delete'                        or tei:datatype                        or tei:valList[ @type eq 'closed']"> Attribute: the definition of the @<value-of select="@ident"/> attribute in the <value-of select="ancestor::*[@ident][1]/@ident"/>
            <value-of select="' '"/>
            <value-of select="local-name(ancestor::*[@ident][1])"/> should have a closed valList or a datatype</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-noDefault4Required-80">
      <rule context="tei:attDef[@usage eq 'req']">
         <report test="tei:defaultVal">Since the @<value-of select="@ident"/> attribute is required, it will always be specified. Thus the default value (of "<value-of select="normalize-space(tei:defaultVal)"/>") will never be used. Either change the definition of the attribute so it is not required ("rec" or "opt"), or remove the defaultVal element.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-defaultIsInClosedList-twoOrMore-81">
      <rule context="tei:attDef[     tei:defaultVal                                      and tei:valList[ @type eq 'closed']                                      and tei:datatype[ @maxOccurs &gt; 1  or  @minOccurs &gt; 1  or  @maxOccurs eq 'unbounded']                                    ]">
         <assert test="tokenize(normalize-space(tei:defaultVal),' ') = tei:valList/tei:valItem/@ident">In the <value-of select="local-name(ancestor::*[@ident][1])"/> defining <value-of select="ancestor::*[@ident][1]/@ident"/> the default value of the @<value-of select="@ident"/> attribute is not among the closed list of possible values</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-defaultIsInClosedList-one-82">
      <rule context="tei:attDef[     tei:defaultVal                                      and tei:valList[ @type eq 'closed']                                      and tei:datatype[                                             not(@maxOccurs)                                         or  ( if ( @maxOccurs castable as xs:integer ) then ( @maxOccurs cast as xs:integer eq 1 ) else false() )                                                      ]                                    ]">
         <assert test="string(tei:defaultVal) = tei:valList/tei:valItem/@ident">In the <value-of select="local-name(ancestor::*[@ident][1])"/> defining <value-of select="ancestor::*[@ident][1]/@ident"/> the default value of the @<value-of select="@ident"/> attribute is not among the closed list of possible values</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-restrictDataFacet-83">
      <rule context="tei:dataRef[tei:dataFacet]">
         <assert test="@name" role="nonfatal">Data facets can only be specified for references to datatypes specified by XML Schema Part 2: Datatypes Second Edition — that is, for there to be a 'dataFacet' child there must be a @name attribute.</assert>
         <report test="@restriction" role="nonfatal">Data facets and restrictions cannot both be expressed on the same data reference — that is, the @restriction attribute cannot be used when a 'dataFacet' element is present.</report>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-restrictAttResctrictionName-84">
      <rule context="tei:dataRef[@restriction]">
         <assert test="@name" role="nonfatal">Restrictions can only be specified for references to datatypes specified by XML Schema Part 2: Datatypes Second Edition — that is, for there to be a @restriction attribute there must be a @name attribute, too.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-linkTargets3-85">
      <rule context="tei:link">
         <assert test="contains(normalize-space(@target),' ')">You must supply at least two values for @target or on <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-abstractModel-structure-ab-in-l-86">
      <rule context="tei:l//tei:ab">
         <assert test="ancestor::tei:floatingText | parent::tei:figure | parent::tei:note"> Abstract model violation: Metrical lines may not contain higher-level divisions such as p or ab, unless ab is a child of figure or note, or is a descendant of floatingText.</assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-joinTargets3-87">
      <rule context="tei:join">
         <assert test="contains( normalize-space( @target ),' ')"> You must supply at least two values for @target on <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="schematron-constraint-nested_standOff_should_be_typed-88">
      <rule context="tei:standOff">
         <assert test="@type or not(ancestor::tei:standOff)">This <name/> element must have a @type attribute, since it is nested inside a <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="en-gloss-if-any">
      <rule context="  tei:elementSpec[tei:gloss]                                  | tei:valItem[tei:gloss]                                  | tei:attDef[tei:gloss]                                  | tei:macroSpec[tei:gloss]                                  | tei:classSpec[tei:gloss]                                  | tei:dataSpec[tei:gloss]                                  ">
         <assert test="tei:gloss[ lang('en') ]">If there is any gloss inside <value-of select="name(.)"/>, there must be an English gloss.</assert>
      </rule>
   </pattern>
   <!-- ****************** -->
   <!-- deprecation tests: -->
   <!-- ****************** -->
   <pattern>
      <rule context="tei:superEntry">
         <report test="true()" role="nonfatal">
                  WARNING: use of deprecated element — The <name/> element will be removed from the TEI on 2027-03-07. 
                </report>
      </rule>
   </pattern>
   <pattern>
      <rule context="tei:re">
         <report test="true()" role="nonfatal">
                  WARNING: use of deprecated element — The <name/> element will be removed from the TEI on 2026-03-10. 
                </report>
      </rule>
   </pattern>
   <!-- **************** -->
   <!-- parameter lists: -->
   <!-- **************** -->
   <pattern id="teipm-model-paramList-1">
      <rule context="tei:param[parent::tei:model/@behaviour='alternate']">
         <assert role="error" test="@name='default'   or  @name='alternate'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: default, alternate</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-2">
      <rule context="tei:param[parent::tei:model/@behaviour='anchor']">
         <assert role="error" test="@name='id'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: id</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-3">
      <rule context="tei:param[parent::tei:model/@behaviour='block']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-4">
      <rule context="tei:param[parent::tei:model/@behaviour='body']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-5">
      <rule context="tei:param[parent::tei:model/@behaviour='break']">
         <assert role="error" test="@name='type'   or  @name='label'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: type, label</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-6">
      <rule context="tei:param[parent::tei:model/@behaviour='cell']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-7">
      <rule context="tei:param[parent::tei:model/@behaviour='cit']">
         <assert role="error" test="@name='content'   or  @name='source'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content, source</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-8">
      <rule context="tei:param[parent::tei:model/@behaviour='document']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-9">
      <rule context="tei:param[parent::tei:model/@behaviour='figure']">
         <assert role="error" test="@name='title'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: title</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-10">
      <rule context="tei:param[parent::tei:model/@behaviour='glyph']">
         <assert role="error" test="@name='uri'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: uri</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-11">
      <rule context="tei:param[parent::tei:model/@behaviour='graphic']">
         <assert role="error" test="@name='url'   or  @name='width'   or  @name='height'   or  @name='scale'   or  @name='title'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: url, width, height, scale, title</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-12">
      <rule context="tei:param[parent::tei:model/@behaviour='heading']">
         <assert role="error" test="@name='content'   or  @name='level'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content, level</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-13">
      <rule context="tei:param[parent::tei:model/@behaviour='index']">
         <assert role="error" test="@name='type'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: type</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-14">
      <rule context="tei:param[parent::tei:model/@behaviour='inline']">
         <assert role="error" test="@name='content'   or  @name='label'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content, label</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-15">
      <rule context="tei:param[parent::tei:model/@behaviour='link']">
         <assert role="error" test="@name='content'   or  @name='uri'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content, uri</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-16">
      <rule context="tei:param[parent::tei:model/@behaviour='list']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-17">
      <rule context="tei:param[parent::tei:model/@behaviour='listItem']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-18">
      <rule context="tei:param[parent::tei:model/@behaviour='metadata']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-19">
      <rule context="tei:param[parent::tei:model/@behaviour='note']">
         <assert role="error" test="@name='content'   or  @name='place'   or  @name='label'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content, place, label</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-20">
      <rule context="tei:param[parent::tei:model/@behaviour='paragraph']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-21">
      <rule context="tei:param[parent::tei:model/@behaviour='row']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-22">
      <rule context="tei:param[parent::tei:model/@behaviour='section']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-23">
      <rule context="tei:param[parent::tei:model/@behaviour='table']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-24">
      <rule context="tei:param[parent::tei:model/@behaviour='text']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
   <pattern id="teipm-model-paramList-25">
      <rule context="tei:param[parent::tei:model/@behaviour='title']">
         <assert role="error" test="@name='content'">
          Parameter name '<value-of select="@name"/>'  (on <value-of select="ancestor::tei:elementSpec/@ident"/>) not allowed.
          Must  be  drawn from the list: content</assert>
      </rule>
   </pattern>
</schema>