<?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 2015-10-15T19:58:27Z 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="s" uri="http://www.ascc.net/xml/schematron"/>
   <ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/>
   <ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/>
   <ns prefix="teix" uri="http://www.tei-c.org/ns/Examples"/>

   <!-- ********************* -->
   <!-- namespaces, implicit: -->
   <!-- ********************* -->
   <ns prefix="dcr" uri="http://www.isocat.org/ns/dcr"/>
   <ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
   <ns prefix="teix" uri="http://www.tei-c.org/ns/Examples"/>

   <!-- ************ -->
   <!-- constraints: -->
   <!-- ************ -->
   <pattern id="tei_all-att.datable-calendar-constraint-calendar-1">
          <rule context="tei:*[@calendar]">
            <assert test="string-length(.) gt 0">
@calendar indicates the system or calendar 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="tei_all-att.typed-constraint-subtypeTyped-2">
      <rule context="*[@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="tei_all-att.pointing-targetLang-constraint-targetLang-3">
          <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="tei_all-att.spanning-spanTo-constraint-spanTo-2-4">
          <rule context="tei:*[@spanTo]">
            <assert test="id(substring(@spanTo,2)) and following::*[@xml:id=substring(current()/@spanTo,2)]">
The element indicated by @spanTo (<value-of select="@spanTo"/>) must follow the current element <name/>
                  </assert>
          </rule>
        </pattern>
   <pattern id="tei_all-att.styleDef-schemeVersion-constraint-schemeVersionRequiresScheme-5">
          <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="tei_all-p-constraint-abstractModel-p-6">
      <rule context="tei:p">
         <report test="(ancestor::tei:p or ancestor::tei:ab)          and not(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 contain other paragraphs or ab elements.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-p-constraint-abstractModel-structure-l-7">
      <rule context="tei:p">
         <report test="ancestor::tei:l[not(.//tei:note//tei:p[. = current()])]">
        Abstract model violation: Lines may not contain higher-level structural elements such as div, p, or ab.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-ptr-constraint-ptrAtts-8">
      <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="tei_all-ref-constraint-refAtts-9">
      <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="tei_all-list-constraint-gloss-list-must-have-labels-10">
      <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="tei_all-biblStruct-constraint-deprecate-altIdentifier-child-11">
      <rule context="tei:biblStruct">
         <report test="child::tei:idno" role="nonfatal">WARNING: use of deprecated method — the use of the idno element as a direct child of the biblStruct element will be removed from the TEI on 2016-09-18</report>
      </rule>
   </pattern>
   <pattern id="tei_all-relatedItem-constraint-targetorcontent1-12">
      <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="tei_all-l-constraint-abstractModel-structure-l-13">
      <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="tei_all-lg-constraint-atleast1oflggapl-14">
      <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="tei_all-lg-constraint-abstractModel-structure-l-15">
      <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="tei_all-s-constraint-noNestedS-16">
      <rule context="tei:s">
         <report test="tei:s">You may not nest one s element within
      another: use seg instead</report>
      </rule>
   </pattern>
   <pattern id="tei_all-span-constraint-targetfrom-17">
      <rule context="tei:span">
         <report test="@from and @target">
Only one of the attributes @target and @from may be supplied on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="tei_all-span-constraint-targetto-18">
      <rule context="tei:span">
         <report test="@to and @target">
Only one of the attributes @target and @to may be supplied on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="tei_all-span-constraint-tonotfrom-19">
      <rule context="tei:span">
         <report test="@to and not(@from)">
If @to is supplied on <name/>, @from must be supplied as well</report>
      </rule>
   </pattern>
   <pattern id="tei_all-span-constraint-tofrom-20">
      <rule context="tei:span">
         <report test="contains(normalize-space(@to),' ') or contains(normalize-space(@from),' ')">
The attributes @to and @from on <name/> may each contain only a single value</report>
      </rule>
   </pattern>
   <pattern id="tei_all-quotation-constraint-quotationContents-21">
      <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="tei_all-f-constraint-fValConstraints-22">
      <rule context="tei:fVal">
        <assert test="not(tei:* and text)"> A feature value cannot
    contain both text and element content</assert>
      </rule>
      <rule context="tei:fVal">
        <report test="count(tei:*)&gt;1"> A feature value can contain
    only one child element</report>
      </rule>
    </pattern>
   <pattern id="tei_all-link-constraint-linkTargets3-23">
      <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="tei_all-ab-constraint-abstractModel-structure-p-24">
      <rule context="tei:ab">
         <report test="(ancestor::tei:p or ancestor::tei:ab)          and not(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: ab may not contain paragraphs or other ab elements.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-ab-constraint-abstractModel-structure-l-25">
      <rule context="tei:ab">
         <report test="ancestor::tei:l or ancestor::tei:lg">
        Abstract model violation: Lines may not contain higher-level divisions such as p or ab.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-join-constraint-joinTargets3-26">
      <rule context="tei:join">
         <assert test="contains(@target,' ')">
You must supply at least two values for @target on <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="tei_all-dimensions-constraint-duplicateDim-27">
      <rule context="tei:dimensions">
         <report test="count(tei:width)&gt; 1">
The element <name/> may appear once only
      </report>
         <report test="count(tei:height)&gt; 1">
The element <name/> may appear once only
      </report>
         <report test="count(tei:depth)&gt; 1">
The element <name/> may appear once only
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-msIdentifier-constraint-msId_minimal-28">
      <rule context="tei:msIdentifier">
         <report test="not(parent::tei:msPart) and       (local-name(*[1])='idno' or       local-name(*[1])='altIdentifier' or       normalize-space(.)='')">An msIdentifier must contain either a repository or location of some type, or a manuscript name</report>
      </rule>
   </pattern>
   <pattern id="tei_all-msPart-constraint-deprecate-altIdentifier-child-29">
      <rule context="tei:msPart">
         <report test="child::tei:altIdentifier" role="nonfatal">WARNING: use of deprecated method — the use of the altIdentifier element as a direct child of the msPart element will be removed from the TEI on 2016-09-09</report>
      </rule>
   </pattern>
   <pattern id="tei_all-relation-constraint-reforkeyorname-30">
      <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="tei_all-relation-constraint-activemutual-31">
      <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="tei_all-relation-constraint-activepassive-32">
      <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="tei_all-shift-constraint-shiftNew-33">
      <rule context="tei:shift">
         <assert test="@new" role="warning">              
The @new attribute should always be supplied; use the special value
"normal" to indicate that the feature concerned ceases to be
remarkable at this point.</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-rdgGrp-constraint-only1lem-34">
      <rule context="tei:rdgGrp">
         <assert test="count(tei:lem) &lt; 2">Only one &lt;lem&gt; element may appear within a &lt;rdgGrp&gt;</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-variantEncoding-location-constraint-variantEncodingLocation-35">
          <rule context="tei:variantEncoding">
            <assert test="(@location != 'external') or (@method != 'parallel-segmentation')">
              The @location value "external" is inconsistent with the
              parallel-segmentation method of apparatus markup.</assert>
          </rule>
        </pattern>
   <pattern id="tei_all-div-constraint-abstractModel-structure-l-38">
      <rule context="tei:div">
         <report test="ancestor::tei:l">
        Abstract model violation: Lines may not contain higher-level structural elements such as div.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-div-constraint-abstractModel-structure-p-39">
      <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.
      </report>
      </rule>
   </pattern>
   <pattern id="tei_all-addSpan-constraint-spanTo-40">
      <rule context="tei:addSpan">
         <assert test="@spanTo">The @spanTo attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-damageSpan-constraint-spanTo-42">
      <rule context="tei:damageSpan">
         <assert test="@spanTo">
The @spanTo attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-delSpan-constraint-spanTo-44">
      <rule context="tei:delSpan">
         <assert test="@spanTo">The @spanTo attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-subst-constraint-substContents1-46">
      <rule context="tei:subst">
         <assert test="child::tei:add and child::tei:del">
            <name/> must have at least one child add and at least one child del</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-att.identified-constraint-spec-in-module-47">
      <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="tei_all-att.deprecated-validUntil-constraint-deprecated-48">
          <rule context="tei:*[@validUntil]">
            <assert test="@validUntil cast as xs:date ge          current-date()">
            <value-of select="if          (@ident) then concat('The ',@ident) else          concat('This ',local-name(.),' of          ',ancestor::tei:*[@ident][1]/@ident)"/>
	    construct is outdated (as of <value-of select="@validUntil"/>); ODD processors may ignore it, and its use is no longer supported</assert>
            <assert role="nonfatal"
                 test="@validUntil cast as xs:date ge          (current-date() + (60*xs:dayTimeDuration('P1D')))">
            <value-of select="if (@ident) then concat('The ',@ident) else concat('This ',local-name(.),' of ',ancestor::tei:*[@ident][1]/@ident)"/>  construct becomes outdated on <value-of select="@validUntil"/>
         </assert>
          </rule>
        </pattern>
   <pattern id="tei_all-moduleRef-constraint-modref-49">
      <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="tei_all-moduleRef-prefix-constraint-not-same-prefix-50">
          <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="tei_all-sequence-constraint-sequencechilden-51">
      <rule context="tei:sequence">
         <assert test="count(*)&gt;1">The sequence element must have at least two child elements</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-alternate-constraint-alternatechilden-52">
      <rule context="tei:alternate">
         <assert test="count(*)&gt;1">The alternate element must have at least two child elements</assert>
      </rule>
   </pattern>
   <pattern id="tei_all-constraintSpec-constraint-sch-53">
      <rule context="tei:constraintSpec">
      
         <report test="tei:constraint/s:*  and  @scheme ne 'schematron'">Rules in the Schematron 1.* language must be inside a constraintSpec with a value of 'schematron' on the scheme attribute</report>
      </rule>
   </pattern>
   <pattern id="tei_all-constraintSpec-constraint-isosch-54">
      <rule context="tei:constraintSpec">
      
         <report test="tei:constraint/sch:*  and  @scheme ne 'isoschematron'">Rules in the ISO Schematron language must be inside a constraintSpec with a value of 'isoschematron' on the scheme attribute</report>
      </rule>
   </pattern>
   <pattern id="tei_all-constraintSpec-constraint-xslt-55">
      <rule context="tei:constraintSpec">
      
         <report test="tei:constraint/xsl:*  and  @scheme ne 'XSLT'">Rules in XSLT must be inside a constraintSpec with a value of 'isoschematron' on the scheme attribute</report>
      </rule>
   </pattern>
   <pattern id="tei_all-constraintSpec-constraint-needrules-56">
      
      <rule context="tei:macroSpec/tei:constraintSpec[@scheme='isoschematron']/tei:constraint">
	        <report test="sch:assert|sch:report">An ISO Schematron constraint specification for a macro should not have an 'assert' or 'report' element without a parent 'rule' element</report>
      </rule>
    </pattern>
   <pattern id="tei_all-attDef-constraint-attDefContents-57">
      <rule context="tei:attDef">
      
         <assert test="ancestor::teix:egXML[@valid='feasible'] or @mode eq 'change' or @mode eq 'delete' or tei:datatype or tei:valList[@type='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="tei_all-attDef-constraint-noDefault4Required-58">
      <rule context="tei:attDef[@usage eq 'req']">
	        <report test="tei:defaultVal">It does not make sense to make "<value-of select="normalize-space(tei:defaultVal)"/>" the default value of @<value-of select="@ident"/>, because that attribute is required.</report>
      </rule>
    </pattern>
   <pattern id="tei_all-attDef-constraint-defaultIsInClosedList-twoOrMore-59">
      <rule context="tei:attDef[   tei:defaultVal   and   tei:valList[@type eq 'closed']   and   tei:datatype[    @maxOccurs &gt; 1    or    @minOccurs &gt; 1    or    @maxOccurs = '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="tei_all-attDef-constraint-defaultIsInClosedList-one-60">
      <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>

   <!-- *********** -->
   <!-- deprecated: -->
   <!-- *********** -->
   <pattern>
      <rule context="tei:teiHeader">
         <report test="@type" role="nonfatal">WARNING: use of deprecated attribute — @type of the teiHeader element will be removed from the TEI on 2016-11-18.
                </report>
      </rule>
   </pattern>
</schema>
