<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright TEI Consortium. 
Dual-licensed under CC-by and BSD2 licences 
See the file COPYING.txt for details
$Date: 2012-10-07 23:37:24 +0100 (Sun, 07 Oct 2012) $
$Id: constraintSpec.xml 10940 2012-10-07 22:37:24Z louburnard $
-->
<elementSpec xmlns:s="http://www.ascc.net/xml/schematron" xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns="http://www.tei-c.org/ns/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" module="tagdocs" ident="constraintSpec">
  <gloss>constraint on schema</gloss>
  <desc>contains  a constraint, expressed in some formal syntax,
  which cannot be expressed in the structural content model</desc>
  <classes>
    <memberOf key="att.global"/>
    <memberOf key="att.identified"/>
    <memberOf key="att.typed"/>
  </classes>
  <content>
    <rng:zeroOrMore>
      <rng:ref name="model.descLike"/>
</rng:zeroOrMore>
<rng:zeroOrMore>
      <rng:ref name="model.glossLike"/>
    </rng:zeroOrMore>
    <rng:optional>
      <rng:ref name="constraint"/>
    </rng:optional>
  </content>
  <constraintSpec ident="sch" scheme="isoschematron">
    <desc>Relationship between scheme attribute and contents</desc>
    <constraint>
      <sch:ns prefix="s" uri="http://www.ascc.net/xml/schematron"/>
      <sch: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
      </sch:report>
    </constraint>
  </constraintSpec>
  <constraintSpec ident="isosch" scheme="isoschematron">
    <constraint>
      <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/>
      <sch: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
      </sch:report>
    </constraint>
  </constraintSpec>
  <attList>
    <attDef ident="scheme" usage="req">
      <equiv/>
      <desc>supplies the name of the language in which the constraints
      are defined</desc>
      <datatype>
        <rng:ref xmlns:rng="http://relaxng.org/ns/structure/1.0" name="data.enumerated"/>
      </datatype>
      <valList type="closed">
        <valItem ident="schematron">
          <gloss>Schematron</gloss>
        </valItem>
        <valItem ident="isoschematron">
          <gloss>ISO Schematron</gloss>
        </valItem>
        <valItem ident="xsl">
          <gloss>XSLT</gloss>
        </valItem>
        <valItem ident="private">
          <gloss>private constraint language</gloss>
        </valItem>
      </valList>
    </attDef>
  </attList>
  <exemplum xml:lang="en">
    <p>This constraint uses Schematron to enforce the presence of the
    <att>spanTo</att> attribute (which comes from an attribute class)
    on the <gi>addSpan</gi> element: </p>
    <egXML xmlns="http://www.tei-c.org/ns/Examples">
      <constraintSpec ident="demo-c1" scheme="isoschematron">
        <desc>Enforce the presence of the <att>spanTo</att> attribute</desc>
        <constraint>
          <sch:assert test="@spanTo">The spanTo= attribute of <sch:name/>
	  is required.</sch:assert>
        </constraint>
      </constraintSpec>
    </egXML>
  </exemplum>
  <exemplum xml:lang="en">
    <egXML xmlns="http://www.tei-c.org/ns/Examples">
      <constraintSpec ident="demo-c2" scheme="isoschematron">
        <desc>Implement an accessibility rule which says that pictures should
    have textual explanations</desc>
        <constraint>
          <sch:report test="not(tei:figDesc or tei:head)"> You should
	  provide information in a figure from which
	  we can construct an alt attribute in HTML </sch:report>
        </constraint>
      </constraintSpec>
    </egXML>
  </exemplum>
  <exemplum xml:lang="en">
    <p>This constraint uses a language which is not
    expressed in XML to check whether the title and author are identical: </p>
    <egXML xmlns="http://www.tei-c.org/ns/Examples">
      <constraintSpec ident="local" scheme="private">
        <constraint> 
(output = leq(title,author)  "title and author cannot be the same")
	</constraint>
      </constraintSpec>
    </egXML>
  </exemplum>
  <listRef>
    <ptr target="#TDTAG"/>
  </listRef>
</elementSpec>
