namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace ns1 = "http://www.tei-c.org/ns/Examples"
namespace rng = "http://relaxng.org/ns/structure/1.0"
namespace s = "http://www.ascc.net/xml/schematron"

# Schema generated 2008-11-01T14:14:38Z
# Edition: 1.2.0. Last updated on October 31st 2008.
# Copyright 2008 TEI Consortium.
# This is free software; you can redistribute it and/or
#	    modify it under the terms of the GNU General Public
#	    License as published by the Free Software Foundation;
#	    either version 2 of the License, or (at your option) any
#	    later version.
# This material is distributed in the hope that it will be
#	    useful, but without any warranty; without even the implied
#	    warranty of merchantability or 
#	    fitness for a particular
#	    purpose. See the GNU General Public License for more
#	    details.
# A copy of the GNU General Public
#	    License is stored on the TEI web site
#	    along with this file; you can also contact the Free
#	    Software Foundation, Inc., 59 Temple Place, Suite 330,
#	    Boston, MA 02111-1307, USA, for a copy.
# For information about the TEI, including contact
#		details, consult the TEI web
#	      site at http://www.tei-c.org/. 
#		Documentation of TEI modules

# Definitions from module tagdocs

# Set global predeclared macros

# Set predeclared macros

# 0. predeclared macros

# 1. classes
att.identified.attributes =
  att.identified.attribute.ident,
  att.identified.attribute.predeclare,
  att.identified.attribute.module,
  att.identified.attribute.mode,
  empty
att.identified.attribute.ident =
  ## Supplies the identifier by which this element is referenced.
  attribute ident { data.name }
att.identified.attribute.predeclare =
  ## Says whether this object should be predeclared in the
  ##       tei infrastructure module.
  [ a:defaultValue = "false" ] attribute predeclare { xsd:boolean }?
att.identified.attribute.module =
  ## Supplies the name of the module in which this object is to
  ##       be defined.
  attribute module { xsd:NCName }?
att.identified.attribute.mode =
  ## specifies the effect of this declaration on its parent
  ##     module.
  [ a:defaultValue = "add" ]
  attribute mode {
    ## this declaration is added to the current definitions
    "add" | ## this declaration and all of its children are removed from the current setup
      "delete" | ## this declaration changes the declaration of the same
      ##     name in the current definition
      "change" | ## this declaration replaces the declaration of the same
      ##     name in the current definition
      "replace"
  }?
# 2. elements

altIdent =
  ## (alternate identifier) supplies the recommended XML name for an element, class,
  ##   attribute, etc. in some language.
  element altIdent { altIdent.content, altIdent.localattributes }
altIdent.content = macro.xtext
altIdent.localattributes =
  att.global.attributes, att.typed.attributes, empty

att =
  ## (attribute) contains the name of an attribute appearing within running text.
  element att { att.content, att.localattributes }
att.content = text
att.localattributes =
  att.global.attributes,
  ## supplies an identifier for  the scheme in which this name is defined.
  ## Sample values include: 1] TEI (text encoding initiative); 2] DBK (docbook); 3] XX (unknown)
  [ a:defaultValue = "TEI" ] attribute scheme { data.enumerated }?,
  empty

attDef =
  ## (attribute definition) contains the definition of a single attribute.
  element attDef { attDef.content, attDef.localattributes }
attDef.content =
  model.glossLike*,
  datatype?,
  defaultVal?,
  (valList | valDesc)?,
  exemplum*,
  remarks*
attDef.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## specifies the optionality of an attribute or element.
  [ a:defaultValue = "opt" ]
  attribute usage {
    ## (required) 
    "req" | ## (mandatory when applicable  ) 
      "mwa" | ## (recommended  ) 
      "rec" | ## (recommended when applicable  ) 
      "rwa" | ## (optional ) 
      "opt"
  }?,
  ## (namespace) specifies the namespace to which this attribute belongs
  [ a:defaultValue = "http://www.tei-c.org/ns/1.0" ]
  attribute ns { data.namespace }?,
  empty

attList =
  ## contains documentation for all the attributes associated with this
  ## element, as a series of attDef elements.
  element attList { attList.content, attList.localattributes }
attList.content = (attRef | attDef | attList)+
attList.localattributes =
  att.global.attributes,
  ## (organization) specifies whether all the attributes in the list are
  ##   available (org="group") or only  one of them (org="choice")
  [ a:defaultValue = "group" ]
  attribute org {
    ## grouped
    "group" | ## alternated
      "choice"
  }?,
  empty

attRef =
  ## (attribute pointer) points to the definition of an attribute or group of attributes.
  element attRef { attRef.content, attRef.localattributes }
attRef.content = empty
attRef.localattributes =
  att.global.attributes,
  ## the name of the pattern defining the attribute(s)
  attribute name { data.word },
  empty

classSpec =
  ## (class specification) contains reference information for a TEI element class; 
  ## that is a group of 
  ##   elements which appear together in  content models, or 
  ##   which share some common attribute, or both.
  element classSpec { classSpec.content, classSpec.localattributes }
classSpec.content =
  model.glossLike*, classes?, attList?, exemplum*, remarks*, listRef*
classSpec.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## indicates whether this is a model class or an attribute class
  attribute type {
    ## (content model) members of this class appear in the same  content models
    "model" | ## (attributes) members of this class share common attributes
      "atts"
  },
  ## indicates which alternation and sequence instantiations
  ##	of a model class may be referenced. By default, all variations
  ##	are permitted.
  ## Sorry, unable to create schema that uses actual counts minOccurs=1 and maxOccurs=5; approximating to minOccurs=1 and maxOccurs=unbounded.
  attribute generate {
    list {
      (
       ## members of the class are alternatives
       "alternation" | ## members of the class are to be provided in sequence
         "sequence" | ## members of the class may be provided, in sequence,
         ##	    but are optional
         "sequenceOptional" | ## members of the class may be provided one or more
         ##	    times, in sequence, but are optional. 
         "sequenceOptionalRepeatable" | ## members of the class may be provided one or more times, in sequence
         "sequenceRepeatable"),
      (
       ## members of the class are alternatives
       "alternation" | ## members of the class are to be provided in sequence
         "sequence" | ## members of the class may be provided, in sequence,
         ##	    but are optional
         "sequenceOptional" | ## members of the class may be provided one or more
         ##	    times, in sequence, but are optional. 
         "sequenceOptionalRepeatable" | ## members of the class may be provided one or more times, in sequence
         "sequenceRepeatable")*
    }
  }?,
  empty

classes =
  ## specifies all the classes of which the documented element or
  ## class is a member or subclass.
  element classes { classes.content, classes.localattributes }
classes.content = memberOf*
classes.localattributes =
  att.global.attributes,
  ## specifies the effect of this declaration on its parent
  ##     module.
  [ a:defaultValue = "replace" ]
  attribute mode {
    ## this declaration changes the declaration of the same
    ##     name in the current definition
    "change" | ## this declaration replaces the declaration of the same
      ##     name in the current definition
      "replace"
  }?,
  empty

code =
  ## contains literal code from some formal language such as a
  ## programming language.
  element code { code.content, code.localattributes }
code.content = text
code.localattributes =
  att.global.attributes,
  ## (formal language) a name identifying the formal language in which  the
  ##	code is expressed
  attribute lang { data.word }?,
  empty

content =
  ## (content model) contains the text of a declaration for the schema
  ## documented.
  element content { content.content, content.localattributes }
content.content = (macro.schemaPattern | valList)*
content.localattributes = att.global.attributes, empty

datatype =
  ## specifies the declared value for an attribute, by referring to
  ##   any datatype defined by the chosen schema language.
  element datatype { datatype.content, datatype.localattributes }
datatype.content = macro.schemaPattern*
datatype.localattributes =
  att.global.attributes,
  ## (minimum number of occurences) indicates the minimum number of times this datatype may
  ##       occur in the specification of the attribute being defined
  [ a:defaultValue = "1" ] attribute minOccurs { data.count }?,
  ## (maximum number of occurences) indicates the maximum number of times this datatype may
  ##       occur in the specification of the attribute being defined
  [ a:defaultValue = "1" ]
  attribute maxOccurs { data.count | "unbounded" }?,
  empty

defaultVal =
  ## (default value) specifies the default declared value for an attribute.
  element defaultVal { defaultVal.content, defaultVal.localattributes }
defaultVal.content = text
defaultVal.localattributes = att.global.attributes, empty

eg =
  ## (example) contains any kind of illustrative example. 
  element eg { eg.content, eg.localattributes }
eg.content = text
eg.localattributes =
  att.global.attributes, att.xmlspace.attributes, empty

egXML =
  ## (example of XML) contains a single well-formed XML fragment demonstrating the
  ##   use of some XML element or attribute, in which the egXML
  ##   element itself functions as the root element. 
  element ns1:egXML { egXML.content, egXML.localattributes }
egXML.content = macro.anyXML*
egXML.localattributes =
  att.global.attributes, att.xmlspace.attributes, empty

elementSpec =
  ## (element specification) documents the structure, content, and purpose of a single
  ## element type.
  element elementSpec {
    elementSpec.content, elementSpec.localattributes
  }
elementSpec.content =
  model.glossLike*,
  classes?,
  content?,
  attList?,
  exemplum*,
  remarks*,
  listRef*
elementSpec.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## (namespace) specifies the namespace to which this element belongs
  [ a:defaultValue = "http://www.tei-c.org/ns/1.0" ]
  attribute ns { data.namespace }?,
  ## specifies the optionality of an attribute or element. 
  [ a:defaultValue = "opt" ]
  attribute usage {
    ## (required) 
    "req" | ## (mandatory when applicable) 
      "mwa" | ## (recommended) 
      "rec" | ## (recommended when applicable) 
      "rwa" | ## (optional) 
      "opt"
  }?,
  empty

equiv =
  ## (equivalent) specifies a component which is considered equivalent to the
  ##   parent element, either by co-reference, or by external link.
  element equiv { equiv.content, equiv.localattributes }
equiv.content = empty
equiv.localattributes =
  att.global.attributes,
  att.internetMedia.attributes,
  ## names the underlying concept of which the parent is a
  ##   representation
  attribute name { data.name }?,
  ## (uniform resource identifier) references the underlying concept of which the parent is a
  ##   representation by means of some external identifier
  attribute uri { data.pointer }?,
  ## references an external script which contains a method to
  ## transform instances of this element to canonical TEI
  attribute filter { data.pointer }?,
  empty

exemplum =
  ## groups an example demonstrating the use of an element along
  ## with optional paragraphs of commentary.
  element exemplum { exemplum.content, exemplum.localattributes }
exemplum.content = model.pLike*, (egXML | eg), model.pLike*
exemplum.localattributes =
  att.global.attributes,
  att.typed.attributes,
  att.translatable.attributes,
  empty

gi =
  ## (element name) contains the name (generic identifier) of an element.
  element gi { gi.content, gi.localattributes }
gi.content = text
gi.localattributes =
  att.global.attributes,
  ## supplies the name of the scheme in which this name is defined.
  ## Sample values include: 1] TEI (text encoding initiative); 2] DBK (docbook); 3] XX (unknown)
  [ a:defaultValue = "TEI" ] attribute scheme { data.enumerated }?,
  empty

ident =
  ## (identifier) contains an identifier or name for an object of some kind in a formal language.
  element ident { ident.content, ident.localattributes }
ident.content = text
ident.localattributes =
  att.global.attributes, att.typed.attributes, empty

listRef =
  ## (list of references) supplies a list of significant references to places where this
  ##   element is discussed, in the current document or elsewhere.
  element listRef { listRef.content, listRef.localattributes }
listRef.content = ptr+
listRef.localattributes = att.global.attributes, empty

macroSpec =
  ## (macro specification) documents the function and implementation of a pattern. 
  element macroSpec { macroSpec.content, macroSpec.localattributes }
macroSpec.content =
  model.glossLike*,
  (stringVal | content)+,
  exemplum*,
  remarks*,
  listRef*
macroSpec.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## indicates which type of entity should be generated, when an ODD
  ##	processor is generating a module using XML DTD syntax.
  attribute type {
    ## (parameter entity) 
    "pe" | ## (datatype entity) 
      "dt"
  }?,
  empty

memberOf =
  ## specifies  class membership of the parent element or class.
  element memberOf { memberOf.content, memberOf.localattributes }
memberOf.content = macro.xtext
memberOf.localattributes =
  att.global.attributes,
  ## specifies the identifier for a class of which the documented
  ##  element or class is a member or subclass
  attribute key { data.name }?,
  ## specifies the effect of this declaration on its parent
  ##     module.
  [ a:defaultValue = "add" ]
  attribute mode {
    ## this declaration is added to the current definitions
    "add" | ## this declaration and all of its children are removed from the current setup
      "delete"
  }?,
  empty

moduleRef =
  ## (module reference) references a module which is to be incorporated into a schema.
  element moduleRef { moduleRef.content, moduleRef.localattributes }
moduleRef.content =
  (content?)
  >> s:pattern [
       name = "testschemapattern"
       "\x{a}" ~
       "      "
       s:rule [
         context = "tei:moduleRef"
         "\x{a}" ~
         "        "
         s:report [
           test = "* and @key"
           "\x{a}" ~
           "	  child elements of moduleRef are only allowed when an external module\x{a}" ~
           "	  is being loaded\x{a}" ~
           "	"
         ]
         "\x{a}" ~
         "      "
       ]
       "\x{a}" ~
       "    "
     ]
moduleRef.localattributes =
  att.global.attributes,
  (
   ## the name of a TEI module
   attribute key { xsd:NCName }? | ## (uniform resource locator) refers to a non-TEI module of RELAX NG code by external location 
     attribute url { data.pointer }?),
  empty

moduleSpec =
  ## (module specification) documents the structure, content, and purpose of a single
  ## module, i.e. a named and externally visible group of declarations.
  element moduleSpec { moduleSpec.content, moduleSpec.localattributes }
moduleSpec.content = model.glossLike*, exemplum*, remarks?, listRef*
moduleSpec.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## type of module to be generated
  attribute type { text }?,
  empty

remarks =
  ## contains any commentary or discussion about the usage of an
  ## element, attribute, class, or entity not otherwise documented within the
  ## containing element.
  element remarks { remarks.content, remarks.localattributes }
remarks.content = model.pLike+
remarks.localattributes =
  att.global.attributes, att.translatable.attributes, empty

schemaSpec =
  ## (schema specification) generates a TEI-conformant schema and documentation for it.
  element schemaSpec { schemaSpec.content, schemaSpec.localattributes }
schemaSpec.content =
  model.glossLike*, (moduleRef | specGrpRef | model.oddDecl)*
schemaSpec.localattributes =
  att.global.attributes,
  att.identified.attributes,
  ## specifies entry points to the schema, i.e. which elements
  ##       are allowed to be used as the root of documents conforming to
  ##       it. 
  [ a:defaultValue = "TEI" ]
  attribute start {
    list { data.name+ }
  }?,
  ## (namespace) specifies the default namespace (if any) applicable to
  ##       components of the schema.
  [ a:defaultValue = "http://www.tei-c.org/ns/1.0" ]
  attribute ns { data.namespace }?,
  ## specifies a prefix which will be appended to all patterns
  ##       relating to TEI elements. This allows for external schemas to be mixed in
  ##       which have elements of the same names as the TEI.
  attribute prefix { data.name }?,
  ## (target language) specifies which language to use when creating
  ##       the objects in a schema if names for elements or attributes are available in more
  ##       than one language, .
  attribute targetLang { data.language }?,
  ## (documentation language) specifies which languages to
  ##       use when creating documentation if  the description for an element, attribute, class or macro
  ##       is available in more than one language, .
  attribute docLang {
    list { data.language+ }
  }?,
  empty

specDesc =
  ## (specification description) indicates that a description of the specified element or class
  ##   should be included at this point within a document.
  element specDesc { specDesc.content, specDesc.localattributes }
specDesc.content = empty
specDesc.localattributes =
  att.global.attributes,
  ## (identifier) supplies the identifier of the documentary element or class for
  ##       which a description is to be obtained.
  attribute key { data.name }?,
  ## (attributes) supplies attribute names for which descriptions should
  ##       additionally be obtained.
  attribute atts {
    list { data.name* }
  }?,
  empty

specGrp =
  ## (specification group) contains any convenient grouping of specifications for use within
  ##   the current module.
  element specGrp { specGrp.content, specGrp.localattributes }
specGrp.content = (model.oddDecl | model.oddRef | model.divPart)*
specGrp.localattributes = att.global.attributes, empty

specGrpRef =
  ## (reference to a specification group) indicates that the  declarations contained by the
  ##   specGrp referenced should be inserted at this point.
  element specGrpRef { specGrpRef.content, specGrpRef.localattributes }
specGrpRef.content = empty
specGrpRef.localattributes =
  att.global.attributes,
  ## points at the specification group  which logically belongs here.
  attribute target { data.pointer },
  empty

specList =
  ## (specification list) marks where a list of descriptions is to be inserted into the prose documentation.
  element specList { specList.content, specList.localattributes }
specList.content = specDesc+
specList.localattributes = att.global.attributes, empty

stringVal =
  ## contains the intended expansion for the entity documented
  ## by a macroSpec element, enclosed by quotation marks.
  element stringVal { stringVal.content, stringVal.localattributes }
stringVal.content = text
stringVal.localattributes = att.global.attributes, empty

tag =
  ## contains text of a complete start- or end-tag, possibly
  ## including attribute specifications, but excluding the opening and
  ## closing markup delimiter characters.
  element tag { tag.content, tag.localattributes }
tag.content = text
tag.localattributes =
  att.global.attributes,
  ## indicates the type of XML tag intended
  attribute type {
    ## a start-tag, with delimiters < and > is intended
    "start" | ## an end-tag, with delimiters </ and > is intended
      "end" | ## a empty tag, with delimiters < and /> is intended
      "empty" | ## a pi (processing instruction), with delimiters <? and ?>  is intended
      "pi" | ## a comment, with delimiters <!-- and -->  is intended
      "comment" | ## a marked-section, with delimiters <[CDATA[ and ]]>  is intended
      "ms"
  }?,
  ## supplies the name of the schema in which this tag is defined.
  [ a:defaultValue = "TEI" ]
  attribute scheme {
    ## (text encoding initiative) This tag is defined as part of the TEI scheme.
    "TEI" | ## (docbook) this tag is part of the Docbook scheme.
      "DBK" | ## (unknown) this tag is part of an unknown scheme.
      "XX"
  }?,
  empty

val =
  ## (value) contains a single attribute value.
  element val { val.content, val.localattributes }
val.content = text
val.localattributes = att.global.attributes, empty

valDesc =
  ## (value description) specifies any semantic or syntactic constraint on the value that
  ## an attribute may take, additional to the information carried by the
  ## datatype element.
  element valDesc { valDesc.content, valDesc.localattributes }
valDesc.content = macro.phraseSeq.limited
valDesc.localattributes =
  att.global.attributes,
  ## specifies the effect of this declaration on its parent module.
  [ a:defaultValue = "add" ]
  attribute mode {
    ## this declaration is added to the current definitions
    "add" | ## this declaration and all of its children are removed from the current setup
      "delete" | ## this declaration changes the declaration of the same
      ##	 name in the current definition
      "change" | ## this declaration replaces the declaration of the same
      ##	name in the current definition
      "replace"
  }?,
  empty

valItem =
  ## documents a single attribute-value within a list of possible
  ##   or mandatory items.
  element valItem { valItem.content, valItem.localattributes }
valItem.content = model.glossLike*
valItem.localattributes =
  att.global.attributes, att.identified.attributes, empty

valList =
  ## (value list) contains one or more valItem elements defining possible
  ##   values for an attribute.
  element valList { valList.content, valList.localattributes }
valList.content = valItem+
valList.localattributes =
  att.global.attributes,
  ## specifies the effect of this declaration on its parent
  ##     module.
  [ a:defaultValue = "add" ]
  attribute mode {
    ## this declaration is added to the current definitions
    "add" | ## this declaration and all of its children are removed from the current setup
      "delete" | ## this declaration changes the declaration of the same
      ##	 name in the current definition
      "change" | ## this declaration replaces the declaration of the same
      ##	name in the current definition
      "replace"
  }?,
  ## specifies the extensibility of the list of attribute values
  ##       specified.
  [ a:defaultValue = "open" ]
  attribute type {
    ## only the values specified are permitted.
    "closed" | ## (semi-open) all the values specified should be supported, but
      ##	  other values are legal and software should have appropriate
      ##	  fallback processing for them.
      "semi" | ## the values specified are sample values only.
      "open"
  }?,
  empty
# 3. macros
