<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
        xmlns:oxdoc="http://www.oxygenxml.com/ns/doc/xsl"
        queryBinding="xslt2">
   <title>ISO Schematron rules</title>
   <!--namespaces:--><ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
   <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"/>
   <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
           prefix="tei"
           uri="http://www.tei-c.org/ns/1.0"/>
   <!--keys:--><!--patterns:--><!--constraints:--><pattern id="att.datable-constraint-calendar">
      <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="att.typed-constraint-subtypeTyped">
      <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="att.pointing-constraint-targetLang">
      <rule context="tei:*[not(self::tei:schemaSpec)][@targetLang]">
            <assert test="count(@target)">@targetLang can only be used if @target is specified.</assert>
          </rule>
   </pattern>
   <pattern id="att.spanning-constraint-spanTo-2">
      <rule context="tei:*[@spanTo]">
         <assert test="following::*[@xml:id=substring(current()/@target,2)]">
The element indicated by @spanTo must follow the current element <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="att.spanning-constraint-spanTo-3">
      <rule context="tei:*[@spanTo]">
         <assert test="id(substring(@spanTo,2))">
@spanTo on <name/> must point to  the identifier of some element  in this document</assert>
      </rule>
   </pattern>
   <pattern id="ptr-constraint-ptrAtts">
      <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="ref-constraint-refAtts">
      <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="relatedItem-constraint-targetorcontent1">
      <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="lg-constraint-atleast1oflggapl">
      <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="s-constraint-noNestedS">
      <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="span-constraint-targetfrom">
      <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="span-constraint-targetto">
      <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="span-constraint-tonotfrom">
      <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="span-constraint-tofrom">
      <rule context="tei:span">
         <report test="contains(@to,' ') or contains(@from,' ')">
The attributes @to and @from on <name/> may each contain only a single value</report>
      </rule>
   </pattern>
   <pattern id="quotation-constraint-quotationContents">
      <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="f-constraint-fValConstraints">
      <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="link-constraint-linkTargets1">
      <rule context="tei:link">
         <report test="@target and @targets">You may not supply both 
	@target and @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="link-constraint-linkTargets2">
      <rule context="tei:link">
         <report test="not(@target) and not(@targets)">You must
	supply either @target or @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="link-constraint-linkTargets3">
      <rule context="tei:link">
         <assert test="contains(@target,' ')">You must supply at least two
values for @target on <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="join-constraint-joinTargets1">
      <rule context="tei:join">
         <report test="@target and @targets">
You may not supply both @target and @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="join-constraint-joinTargets2">
      <rule context="tei:join">
         <report test="not(@target) and not(@targets)">
You must supply either @target or @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="join-constraint-joinTargets3">
      <rule context="tei:join">
         <assert test="contains(@target,' ')">
You must supply at least two values for @target on <name/>
         </assert>
      </rule>
   </pattern>
   <pattern id="alt-constraint-altTargets1">
      <rule context="tei:alt">
         <report test="@target and @targets">You may not supply both 
	@target and @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="alt-constraint-altTargets2">
      <rule context="tei:alt">
         <report test="not(@target) and not(@targets)">You must
	supply either @target or @targets on <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="dimensions-constraint-duplicateDim">
      <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="msIdentifier-constraint-msId_minimal">
      <rule context="tei:msIdentifier">
         <report test="local-name(*[1])='idno' or                              local-name(*[1])='altIdentifier' or        .='' ">
You must supply either a locator of some type or a name for <name/>
         </report>
      </rule>
   </pattern>
   <pattern id="relation-constraint-activemutual">
      <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="relation-constraint-activepassive">
      <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="app-constraint-only1lem">
      <rule context="tei:app">
         <assert test="count( descendant::tei:lem[ generate-id(    current() ) = generate-id(    ancestor::tei:app[1] ) ]) &lt;       2">
Only one &lt;lem&gt; element may appear within a single  apparatus
entry, whether it appears outside a &lt;rdgGrp&gt;
element or within it.</assert>
      </rule>
   </pattern>
   <pattern id="addSpan-constraint-spanTo">
      <rule context="tei:addSpan">
         <assert test="@spanTo">The spanTo= attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="damageSpan-constraint-spanTo">
      <rule context="tei:damageSpan">
         <assert test="@spanTo">
The @spanTo attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="delSpan-constraint-spanTo">
      <rule context="tei:delSpan">
         <assert test="@spanTo">The spanTo= attribute of <name/> is required.</assert>
      </rule>
   </pattern>
   <pattern id="subst-constraint-substContents1">
      <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="moduleRef-constraint-modref">
      <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="moduleRef-constraint-not-same-prefix">
      <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="elementSpec-constraint-elementspec-in-module">
      <rule context="tei:elementSpec">
         <assert test="not( @module )                or                //tei:moduleSpec[ @ident = current()/@module ]                or                //tei:moduleRef[ @key = current()/@module ]">
On element <name/> 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="classSpec-constraint-classspec-in-module">
      <rule context="tei:classSpec">
         <assert test="not( @module )               or               //tei:moduleSpec[ @ident = current()/@module ]               or               //tei:moduleRef[ @key = current()/@module ]">Class
      <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="macroSpec-constraint-macrospec-in-module">
      <rule context="tei:macroSpec">
         <assert test="not( @module )               or               //tei:moduleSpec[ @ident = current()/@module ]               or               //tei:moduleRef[ @key = current()/@module ]">Macro <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="constraintSpec-constraint-sch">
      <rule context="tei:constraintSpec">
         <report test="tei:constraint/s:* and    not(@scheme='schematron')">
	Rules in the Schematron 1.* language must be inside
	a constraint with a value of 'schematron' on the scheme attribute
      </report>
      </rule>
   </pattern>
   <pattern id="constraintSpec-constraint-isosch">
      <rule context="tei:constraintSpec">
         <report test="tei:constraint/sch:* and    not(@scheme='isoschematron')">
	Rules in the ISO Schematron language must be inside
	a constraint with a value of 'isoschematron' on the scheme attribute
      </report>
      </rule>
   </pattern>
   <pattern id="attDef-constraint-attDefContents">
      <rule context="tei:attDef">
         <assert test="   @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>
</schema>
