<?xml version='1.0'?>
<!-- $Id: structures.xsd,v 1.1 1999/09/24 18:18:56 hugo Exp $ -->
<!DOCTYPE schema PUBLIC '-//W3C//DTD XMLSCHEMA 19990923//EN'
                        '../structures/structures.dtd'>

<schema xmlns='http://www.w3.org/1999/09/23-xmlschema/'
        targetNS='http://www.w3.org/1999/09/23-xmlschema/'
        version='0.6'>

  <!-- The datatype element and all of its members are defined
       in XML Schema: Part 2: Datatypes -->

 <include
  schemaName='http://www.w3.org/1999/09/23-xmlschema/datatypes/datatypes.xsd'/>

  <!-- The NCName datatype is widely used for the names of components -->

  <datatype name='NCName'><basetype name='NMTOKEN'/> </datatype>

  <!-- The public datatype is used for entities and notations -->

  <datatype name='public'><basetype name='string'/> </datatype>

  <!-- schema element -->

  <element name='schema'>
    <archetype>
      <element ref='import' minOccurs='0' maxOccurs='*'/>
      <element ref='include' minOccurs='0' maxOccurs='*'/>
      <element ref='export' minOccurs='0'/>
      <group order='choice' minOccurs='0'>
	<element ref='comment'/>
        <element ref='datatype'/>
        <element ref='archetype'/>
        <element ref='element'/>
        <element ref='attrGroup'/>
        <element ref='modelGroup'/>
        <element ref='textEntity'/>
        <element ref='externalEntity'/>
        <element ref='unparsedEntity'/>
        <element ref='notation'/>
      </group>
    <attribute name='targetNS' type='uri'/>
    <attribute name='version' type='string'/>
    <attribute name='xmlns' type='uri'
               default='http://www.w3.org/1999/09/23-xmlschema/'/>
    <attribute name='model' type='NCName' default='closed'>
      <enumeration>
       <literal>open</literal>
       <literal>refinable</literal>
       <literal>closed</literal>
      </enumeration>
     </attribute>
    </archetype>
  </element>

  <!-- comment element -->

  <element name='comment' type='string'/>

  <!-- ################################################ -->
  <!-- Toplevel and named: Fundamental archetypes,
       used hereafter to build the schema. -->
  <!-- A toplevel specifies an export control in addition to a name. -->
  <!-- ################################################ -->

  <!-- named archetype -->

  <archetype name='named' model='refinable'>
    <attribute name='name' type='NCName'/>
  </archetype>

  <!-- toplevel archetype  -->

  <archetype name='toplevel' model='refinable'>
    <refines name='named'/>
    <attribute name='export' type='boolean'/>
  </archetype>

  <!-- ################################################ -->
  <!-- ######### Toplevel elements #################### -->
  <!-- ################################################ -->
  <!-- The datatype definition element is defined in
       XML Schema Part 2: Datatypes.  -->

  <!-- qualifiable archetype
       For references which may be to components of other schemas.
       reference and typeRef are sub-types of qualifiable -->

  <archetype name='qualifiable' model='refinable'>
    <attribute name='schemaName' type='uri'/>
    <attribute name='schemaAbbrev' type='NCName'/>
  </archetype>
   
  <!-- reference archetype
       refines, modelGroupRef and attrGroupRef are all kinds of reference -->

  <archetype name='reference' model='refinable'>
    <refines name='qualifiable'/>
    <attribute name='name' type='NCName'/>
  </archetype>

  <!-- typeRef archetype -->
  <!-- 'element', 'archetype' and 'attribute' are all kinds of typeRef  -->

  <archetype name='typeRef' model='refinable'>
    <refines name='qualifiable'/>
    <attribute name='type' type='NCName'/>
    <attribute name='default' type='string'/>
    <attribute name='fixed' type='string'/>
  </archetype>

  <!-- modelGroup archetype -->
  <!-- modelGroup, group and archetype are all kinds of modelGroup -->

  <archetype name='modelGroup' model='refinable'>
   <attribute name='order' default='seq'>
    <enumeration>
      <literal>choice</literal>
      <literal>seq</literal>
      <literal>all</literal>
     </enumeration>
   </attribute>
  </archetype>

  <!-- modelElt archetype -->
  <!-- the abstract class of all model elements:
        groups, elements and modelGroupRefs -->
  <archetype name='modelElt' model='refinable'>
    <attribute name='minOccurs' type='non-negative-integer' default='1'/>
    <attribute name='maxOccurs' type='string'/> <!-- allows '*', so integer
                                                       won't do -->
  </archetype>

  <!-- The archetype element refines the toplevel, typeRef and
       modelGroup archetypes.
       It may include a refines element that specifies the archetype(s)
       that is is based on, and either a datatypeQual or a model,
       followed by any number of attribute and attrGroupRef elements.  -->
  <!-- archetype element -->

  <element name='archetype'>
    <archetype>
      <refines name='toplevel'/>
      <refines name='typeRef'/>
      <refines name='modelGroup'/>
      <element ref='refines' minOccurs='0' maxOccurs='*'/>
    <group order='choice'>
        <element archRef='modelElt' minOccurs='0' maxOccurs='*'/>
        <element ref='datatypeQual' minOccurs='0'/>
      </group>
     <group order='choice'  minOccurs='0' maxOccurs='*'>
      <element ref='attribute'/>
      <element ref='attrGroupRef'/>
     </group>
      <attribute name='content' default='elemOnly'>
       <enumeration>
        <literal>elemOnly</literal>
      <literal>textOnly</literal>
      <literal>mixed</literal>
      <literal>empty</literal>
      <literal>any</literal>
     </enumeration>
    </attribute>
    <attribute name='model' type='NCName'>
      <!-- default comes from schema model -->
      <enumeration>
       <literal>open</literal>
       <literal>refinable</literal>
       <literal>closed</literal>
      </enumeration>
     </attribute>
    </archetype>
  </element>

  <!-- refines element -->

  <element name='refines'>
    <archetype content='empty'>
     <refines name='reference'/>
    </archetype>
  </element>


  <!-- The element element refines the toplevel and typeRef archetype.
       It can be used either at the toplevel to define an element-type binding
       globally,
       or within a content model to either reference a globally-defined
       element or archetype or declare an element-type binding locally.
       The ref/archRef forms are not allowed at the top level -->
  <!-- element element -->

  <element name='element'>
    <archetype order='choice'>
    <refines name='toplevel'/>
    <refines name='typeRef'/>
    <refines name='modelElt'/>
        <element ref='datatype'/>
        <element ref='archetype'/>
    </archetype>
  </element>

  <!-- The group element refines the modelElt
          and modelGroup archetypes. -->
  <!-- group element -->

  <element name='group'>
   <archetype>
    <refines name='modelElt'/>
    <refines name='modelGroup'/>
    <element archRef='modelElt' minOccurs='2' maxOccurs='*'/>
   </archetype>
  </element>

  <!-- The modelGroup element refines the toplevel
          and modelGroup archetypes. -->
  <!-- modelGroup element -->

  <element name='modelGroup'>
   <archetype>
    <refines name='toplevel'/>
    <refines name='modelGroup'/>
    <element archRef='modelElt' minOccurs='1' maxOccurs='*'/>
   </archetype>
  </element>

  <!-- The modelGroupRef element refines the reference and
       modelElt archetypes -->
  <!-- modelGroupRef element -->

  <element name='modelGroupRef'>
    <archetype content='empty'>
      <refines name='reference'/>
      <refines name='modelElt'/>
    </archetype>
  </element>

  <!-- The datatypeQual archetype provides for modifying datatypes
       referenced from attribute declarations and archetype
       definitions.
       It is realised by the datatypeQual element and refined by the
       attribute element -->

  <archetype name='datatypeQual' order='all'>
	<element archRef='maxBound' minOccurs='0'/>
	<element archRef='minBound' minOccurs='0'/>
        <element ref='maxInclusive' minOccurs='0'/>
        <element ref='minInclusive' minOccurs='0'/>
        <element ref='precision' minOccurs='0'/>
        <element ref='scale' minOccurs='0'/>
        <element ref='length' minOccurs='0'/>
        <element ref='maxLength' minOccurs='0'/>
        <element ref='enumeration' minOccurs='0'/>
        <element ref='lexicalRepresentation' minOccurs='0'/>
  </archetype>

  <!-- The datatypeQual element realises the datatypeQual archetype -->

  <element name='datatypeQual' type='datatypeQual'/>

  <!-- the attribute element declares attributes -->
  <element name='attribute'>
   <archetype>
    <refines name='datatypeQual'/>
    <refines name='typeRef'/>
    <refines name='named'/>
    <attribute name='minOccurs' type='non-negative-integer' default='0'>
      <enumeration>
       <literal>0</literal>
       <literal>1</literal>
      </enumeration>
    </attribute>
    <attribute name='maxOccurs' type='integer' fixed='1'/>
   </archetype>
  </element>

  <!-- attrGroup element -->
  <element name='attrGroup'>
    <archetype>
    <refines name='toplevel'/>
      <group order='choice' minOccurs='1' maxOccurs='*'>
      <element ref='attribute'/>
      <element ref='attrGroupRef'/>
     </group>
    </archetype>
  </element>

  <!-- The attrGroupRef element refines the reference archetype.  -->
  <!-- attrGroupRef element -->
  <element name='attrGroupRef'>
    <archetype>
     <refines name='reference'/>
    </archetype>
  </element>

  <!-- The textEntity element refines the toplevel archetype.
        It provides for string content to specify the entity value.  -->
  <!-- textEntity element -->

  <element name='textEntity'>
    <archetype type='string'>
      <refines name='toplevel'/>
    </archetype>
  </element>

  <!-- The externalRef archetype provides for specification
       of a uri, an optional public identifier, and a notation attribute.
       It refines the toplevel archetype -->

  <archetype name='externalRef' model='refinable' content='empty'>
    <refines name='toplevel'/>
    <attribute name='system' type='uri' minOccurs='1'/>
    <attribute name='public' type='public'/>
  </archetype>

  <!-- the typedExternalRef adds a required notation to an external ref -->
  <archetype name='typedExternalRef' model='refinable'>
    <refines name='externalRef'/>
    <attribute name='notation' type='NOTATION' minOccurs='1'/>
  </archetype>

  <!-- The externalEntity and unparsedEntity elements are
       based on the typedExternalRef archetype. -->
  <!-- externalEntity element -->

  <element name='externalEntity'>
    <archetype>
    <refines name='typedExternalRef'/>
    <attribute name='notation' fixed='XML'/>
   </archetype>
  </element>

<!-- unparsedEntity element -->
  <element name='unparsedEntity'>
    <archetype>
    <refines name='typedExternalRef'/>
   </archetype>
  </element>

  <!-- The notation element refines the externalRef archetype. -->
  <element name='notation'>
    <archetype>
    <refines name='externalRef'/>
   </archetype>
  </element>

  <!-- ################################################ -->
  <!-- import, export and include -->
  <!-- The import, export and include elements all refine the
       restrictions archetype, whose attributes can be used
       to enable or disable import and export restrictions.
       Within import and include elements, references to the
       components of foreign schemas control their importation
       or inclusion, respectively.  -->
  <!-- The import and include elements both refine external -->
  <!-- ################################################ -->

  <archetype name='restrictions' model='refinable'>
    <attribute name='datatypes' type='boolean' default='true'/>
    <attribute name='archetypes' type='boolean' default='true'/>
    <attribute name='elements' type='boolean' default='true'/>
    <attribute name='attrGroups' type='boolean' default='true'/>
    <attribute name='modelGroups' type='boolean' default='true'/>
    <attribute name='entities' type='boolean' default='true'/>
    <attribute name='notations' type='boolean' default='true'/>
  </archetype>

  <archetype name='external' order='choice' model='refinable'>
      <refines name='restrictions'/>
      <element ref='component' minOccurs='0' maxOccurs='*'/>
    <attribute name='schemaName' minOccurs='1' type='uri'/>
  </archetype>

<!-- component element, used in external -->

  <element name='component'>
   <archetype content='empty'>
    <attribute name='name' type='NCName' minOccurs='1'/>
    <attribute name='type' minOccurs='1'>
     <enumeration>
      <literal>datatype</literal>
      <literal>archetype</literal>
      <literal>element</literal>
      <literal>attrGroup</literal>
      <literal>modelGroup</literal>
      <literal>entity</literal>
      <literal>notation</literal>
     </enumeration>
    </attribute>
   </archetype>
  </element>

  <!-- import element  -->

  <element name='import'>
    <archetype>
      <refines name='external'/>
      <attribute name='schemaAbbrev' minOccurs='1' type='NCName'/>
    </archetype>
  </element>

  <!-- export element  -->

  <element name='export'>
    <archetype content='empty'>
    <refines name='restrictions'/>
    </archetype>
  </element>

  <!-- include element  -->

  <element name='include' type='external'/>

  <!-- ################################################ -->
  <!-- notations for use within XML Schema schemas      -->
  <!-- ################################################ -->  
  <notation name='XMLSchemaStructures' 
            public='structures'
            system='http://www.w3.org/1999/09/23-xmlschema/structures/structures.xsd'/>
  <notation name='XML'
            public='REC-xml-19980210'
            system='http://www.w3.org/TR/1998/REC-xml-19980210'/>
</schema>
