<?xml version='1.0'?>
<!-- XML Schema schema for XML Schemas: Part 1: Structures -->
<!-- Note this schema is NOT the normative structures schema - - the
     prose copy in the structures REC is the normative version (which
     shouldn't differ from this one except for this comment and entity
     expansions, but just in case -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19991216//EN" "structures.dtd" [
<!ATTLIST schema xmlns:x CDATA #IMPLIED> <!-- keep this schema XML1.0 valid -->
]>
<schema xmlns="&XMLSchemaNS;" targetNamespace="&XMLSchemaNS;" xmlns:x="http://www.w3.org/XML/1998/namespace" version="$Id: structures.xsd,v 1.29.1.1 1999/12/17 12:27:09 ht Exp $">

 <!-- get access to the xml: attribute groups for xml:lang -->
 <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/XML/1998/xml.xsd"/>


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

  <include schemaLocation="&XSP2.URI;.xsd"/>

  <type name="annotated">
   <annotation>
    <info>This type is extended by all types which allow annotation
          other than &lt;schema> itself</info>
   </annotation>
   <element ref="annotation" minOccurs="0"/>
  </type>

  <element name="schemaTop" abstract="true" type="annotated">
   <annotation>
    <info>This abstract element defines an equivalence class over the
          elements which occur freely at the top level of schemas.
          These are: datatype, type, element, attributeGroup, group, notation
          All of their types are based on the "annotated" type
          by extension.</info>
   </annotation>
  </element>

  <!-- schema element -->

  <element name="schema">
   <annotation>
    <info>The obnoxious duplication in the content model below is to avoid
         infringing the no-ambiguity constraint while still allowing
         annotation virtually anywhere.
         This has the unfortunate consequence of disallowing a schema with
         only import/includes, this should be fixed.</info>
   </annotation>
    <type>
      <group order="choice" minOccurs="0" maxOccurs="*">
       <element ref="include"/>
       <element ref="import"/>
       <element ref="annotation"/>
      </group>
      <element ref="schemaTop"/>
      <group order="choice" minOccurs="0" maxOccurs="*">
        <element ref="annotation"/>
        <element ref="schemaTop"/>
      </group>
    <attribute name="targetNamespace" type="uri"/>
    <attribute name="version" type="string"/>
   <attribute name="finalDefault" type="derivationSet"/>
   <attribute name="exactDefault" type="exactSet"/>
   </type>
  </element>

  <!-- annotation element -->

  <element name="annotation">
   <type>
    <group order="choice" minOccurs="0" maxOccurs="*">
     <element name="appinfo">
       <type content="mixed">
         <any minOccurs="0" maxOccurs="*"/>
         <attribute name="source" type="uri"/>
       </type>
     </element>
     <element name="info">
       <type content="mixed">
         <any minOccurs="0" maxOccurs="*"/>
         <attribute name="source" type="uri"/>
         <attributeGroup ref="x:lang"/>
       </type>
     </element>
    </group>
   </type>
  </element>


  <!-- For references to a type -->
  <!-- 'element', 'attribute' and any all use this  -->

  <attributeGroup name="typeRef">
    <attribute name="type" type="QName"/>
  </attributeGroup>

  <!-- For 'element' and 'attribute' -->
  <attributeGroup name="valueConstraint">
   <attribute name="default" type="string"/>
   <attribute name="fixed" type="string"/>
  </attributeGroup>


  <!-- for all particles -->
  <attributeGroup name="occurs">
    <attribute name="minOccurs" type="non-negative-integer" default="1"/>
    <attribute name="maxOccurs" type="string"/> <!-- allows '*', so integer
                                                       won't do -->
  </attributeGroup>

  <!-- for element, group and attributeGroup, which both define and reference -->
  <attributeGroup name="defRef">
   <attribute name="name" type="NCName" minOccurs="0"/>
   <attribute name="ref" type="QName" minOccurs="0"/>
  </attributeGroup>

  <!-- 'element', 'group' and 'any' -->
  <group name="particle" order="choice">
   <element name="element" type="element"/>
   <element name="group" type="anonGroup"/>
   <element ref="any"/>
  </group>
 
  <group name="restrictionParticle" order="choice">
   <element name="sic"><type content="empty"/></element>
   <group ref="particle"/>
  </group>
 
  <group name="attrDecls">   
   <group order="choice" minOccurs="0" maxOccurs="*">
    <element ref="attribute"/>
    <element ref="attributeGroup"/>
   </group>
   <element name="anyAttribute" type="namespaceList" minOccurs="0"/>
  </group>

  <!-- types for type -->

  <type name="type" source="annotated" derivedBy="extension" abstract="true">
   <group order="choice">
    <element ref="restrictions" minOccurs="0"/>
    <group>
     <group ref="particle" minOccurs="0" maxOccurs="*"/>
     <group ref="attrDecls"/>
    </group>
   </group>
   <attribute name="name" type="NCName" minOccurs="0">
    <annotation>
     <info>Will be restricted to required or forbidden</info>
    </annotation>
   </attribute>
   <attribute name="content">
    <datatype source="NMTOKEN">
     <enumeration value="elementOnly"/>
     <enumeration value="textOnly"/>
     <enumeration value="mixed"/>
     <enumeration value="empty"/>
    </datatype>
   </attribute>
   <attribute name="source" type="QName"/>
   <attribute name="derivedBy" type="derivationChoice"/>
   <attribute name="abstract" type="boolean" default="false"/>
   <attribute name="final" type="derivationSet"/>
   <attribute name="exact" type="derivationSet"/>
  </type>
 
  <type name="namedType" source="type" derivedBy="restriction">
   <annotation>
    <info>This is for the top-level type element, daughter of &lt;schema</info>
   </annotation>
   <attribute name="name" minOccurs="1">
    <annotation><info>Required at the top level</info></annotation>
   </attribute>
  </type>
 
  <type name="anonType" source="type" derivedBy="restriction">
   <annotation>
    <info>This is for the nested type element, daughter of &lt;element</info>
   </annotation>
   <attribute name="name" maxOccurs="0">
    <annotation><info>Forbidden when nested</info></annotation>
   </attribute>
  </type>

  <!-- Top level type element, daughter of schema -->
  <element name="type" equivClass="schemaTop" type="namedType"/> 
 
  <key name="type">
   <selector>schema/type</selector>
   <field>@name</field>
  </key>
 
  <key name="element">
   <selector>schema/element</selector>
   <field>@name</field>
  </key>
 
  <keyref name="datatypeRef" refer="datatype">
   <selector>.//attribute[@type]</selector>
   <field>@type</field>
  </keyref>

  <datatype name="derivationChoice" source="NMTOKEN">
   <enumeration value="extension"/>
   <enumeration value="restriction"/>
  </datatype>

  <datatype name="exactSet" source="string">
   <annotation>
    <info>Should be a sequence drawn from the values of derivationChoice
          plus 'equivClass',
          or #all -- regexp is only an approximation</info>
   </annotation>
   <pattern value="#all?|(equivClass|extension|restriction| )*"/>
  </datatype>

  <datatype name="derivationSet" source="exactSet">
   <annotation>
    <info>Should be a sequence drawn from the values of derivationChoice,
          or #all -- regexp is only an approximation</info>
   </annotation>
   <pattern value="#all?|(extension|restriction| )*"/>
  </datatype>
  <!-- restrictions element -->

  <element name="restrictions">
    <type source="annotated" derivedBy="extension">
     <group order="choice">
      <element ref="facet" minOccurs="0" maxOccurs="*"/>
          <!-- max 1, min 0, for each facet except pattern, period-->
      <group ref="restrictionParticle" minOccurs="0" maxOccurs="*"/>
     </group>
     <group ref="attrDecls"/>
    </type>
  </element>

  <!-- The element element 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 type or declare an element-type binding locally.
       The ref form is not allowed at the top level -->

  <type name="element" source="annotated" derivedBy="extension">
     <group order="choice" minOccurs="0">
      <element name="datatype" type="anonDatatype"/>
      <element name="type" type="anonType"/>
     </group>
     <group order="choice" minOccurs="0" maxOccurs="*">
        <element ref="unique"/>
        <element ref="key"/>
        <element ref="keyref"/>
     </group>
     <attributeGroup ref="defRef"/>
     <attributeGroup ref="typeRef"/>
     <attribute name="equivClass" type="QName"/>
     <attributeGroup ref="occurs"/>
     <attributeGroup ref="valueConstraint"/>
     <attribute name="nullable" type="boolean" default="false"/>
     <attribute name="abstract" type="boolean" default="false"/>
     <attribute name="final" type="boolean" default="false"/>
     <attribute name="exact" type="exactSet"/>
    </type>

  <type name="namedElement" source="element" derivedBy="restriction">
   <restrictions>
    <attribute name="name" minOccurs="1"/> <!-- required at top level -->
    <attribute name="ref" maxOccurs="0"/> <!-- forbidden at top level -->
   </restrictions>
  </type>

  <element name="element" type="namedElement" equivClass="schemaTop"/>

  <!-- group element for named top-level groups, group references and
       anonymous groups in content models -->
  <type name="group" source="annotated" derivedBy="extension" abstract="true">
    <group ref="particle" minOccurs="0" maxOccurs="*"/>
    <attributeGroup ref="defRef"/>
    <attributeGroup ref="occurs"/>
    <attribute name="order" default="seq">
     <datatype source="NMTOKEN">
        <enumeration value="choice"/>
        <enumeration value="seq"/>
        <enumeration value="all"/>  <!-- allowed only at top level -->
      </datatype>
    </attribute>
   </type>

  <type name="namedGroup" source="group" derivedBy="restriction">
   <restrictions>
    <attribute name="name" minOccurs="1"/> <!-- required at top level -->
    <attribute name="ref" maxOccurs="0"/> <!-- forbidden at top level -->
   </restrictions>
  </type>
 
  <type name="anonGroup" source="group" derivedBy="restriction">
   <restrictions> <!-- required at top level -->
    <attribute name="name" maxOccurs="0"/> <!-- forbidden when nested -->
   </restrictions>
  </type>

  <element name="group" equivClass="schemaTop" type="namedGroup"/>

  <!-- The wildcard specifier in content models -->

  <element name="any">
   <type content="empty">
    <attribute name="namespace" type="namespaceList"/>
    <attributeGroup ref="occurs"/>
   </type>
  </element>

  <!-- simple type for the value of the 'namespace' attr of 'any' and
       'anyAttribute' -->
  <!-- Value is
                  ##any      - - any non-conflicting WFXML/attribute at all

                  ##other    - - any non-conflicting WFXML/attribute from
                                  namespace other than targetNS

                  one or     - - any non-conflicting WFXML/attribute from
                  more URI        the listed namespaces
                  references
                  (space separated)

                ##targetNamespace may appear in the above list, to refer to the
                   targetNamespace of the enclosing schema -->

  <datatype name="namespaceList" source="string"/>

  <!-- the attribute element declares attributes -->

  <element name="attribute">
   <type source="annotated" derivedBy="extension">
    <element name="datatype" minOccurs="0">
     <type source="datatype" derivedBy="restriction">
      <attribute name="name" maxOccurs="0">
       <annotation><info>must be nameless</info></annotation>
      </attribute>
     </type>
    </element>
    <attribute name="name" type="NCName" minOccurs="1"/>
    <attributeGroup ref="typeRef"/>
    <attribute name="minOccurs" default="0">
     <datatype source="non-negative-integer">
       <enumeration value="0"/>
       <enumeration value="1"/>
     </datatype>
    </attribute>
    <attribute name="maxOccurs" default="1">
     <datatype source="non-negative-integer">
       <enumeration value="0"/>
       <enumeration value="1"/>
     </datatype>
    </attribute>
    <attributeGroup ref="valueConstraint"/>
   </type>
  </element>

  <!-- attributeGroup element -->

  <type name="attributeGroup" source="annotated" derivedBy="extension" abstract="true">
     <group order="choice" minOccurs="0" maxOccurs="*">
      <element ref="attribute"/>
      <element name="attributeGroup" type="anonAttributeGroup"/>
     </group>
     <element name="anyAttribute" type="namespaceList" minOccurs="0"/>
     <attributeGroup ref="defRef"/>
    </type>

 <type name="namedAttributeGroup" source="attributeGroup" derivedBy="restriction">
   <restrictions>
    <attribute name="name" minOccurs="1"/> <!-- required at top level -->
    <attribute name="ref" maxOccurs="0"/> <!-- forbidden at top level -->
   </restrictions>
 </type>

 <type name="anonAttributeGroup" source="attributeGroup" derivedBy="restriction">
   <restrictions>
    <attribute name="ref" minOccurs="1"/> <!-- required when nested -->
    <attribute name="name" maxOccurs="0"/> <!-- forbidden when nested -->
   </restrictions>
 </type>

 <element name="attributeGroup" type="namedAttributeGroup" equivClass="schemaTop"/>

 <element name="include">
  <type content="empty">
   <attribute name="schemaLocation" type="uri" minOccurs="1"/>
  </type>
 </element>

 <element name="import">
  <type content="empty">
   <attribute name="namespace" type="uri" minOccurs="1"/>
   <attribute name="schemaLocation" type="uri"/>
  </type>
 </element>
 
 <!-- Better reference mechanisms -->
 
 <type name="keybase" source="annotated" derivedBy="extension">
  <element name="selector"/>
  <element name="field" minOccurs="1" maxOccurs="*"/>
  <attribute name="name" type="NCName" minOccurs="1"/>
 </type>

 <element name="unique" type="keybase" equivClass="schemaTop"/>
 <element name="key" type="keybase" equivClass="schemaTop"/>
 <element name="keyref" equivClass="schemaTop">
  <type source="keybase">
   <attribute name="refer" type="QName" minOccurs="1"/>
  </type>
 </element>

  <!-- notation element type -->

  <element name="notation" equivClass="schemaTop">
   <type source="annotated" derivedBy="extension">
    <attribute name="name" type="NCName" minOccurs="1"/>
    <attribute name="public" type="public" minOccurs="1"/>
    <attribute name="system" type="uri"/>
   </type>
  </element>

  <datatype name="public" source="string"/>

  <!-- notations for use within XML Schema schemas      -->

  <notation name="XMLSchemaStructures" public="structures" system="&XSP1.URI;.xsd"/>
  <notation name="XML" public="REC-xml-19980210" system="http://www.w3.org/TR/1998/REC-xml-19980210"/>
</schema>
