<schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:amf="http://amf.openlib.org"
        targetNamespace="http://amf.openlib.org"
        elementFormDefault="qualified"
        attributeFormDefault="unqualified">

 <annotation>
   <documentation>
     Schema for AMF records, see http://openlib.org/home/krichel/ebisu.html
     Simeon Warner (simeon@lanl.gov) - 16Feb2001...
     [CVS: $Id: amf.xsd,v 1.5 2001/03/15 01:11:34 simeon Exp $] 
   </documentation>
 </annotation>


 <!-- root element of AMF record-->
 <element name="amf" type="amf:nounList"/>

 <!-- nounList: one or more nouns in any sequence --> 
 <complexType name="nounList">
   <choice minOccurs="1" maxOccurs="unbounded">
     <element name="document"     type="amf:documentType"/>
     <element name="person"       type="amf:poType"/>
     <element name="organization" type="amf:poType"/>
     <element name="collection"        type="amf:collectionType"/>
   </choice>
 </complexType>

 <!-- content and attribute types for verbs which admit one
      or more noun elements and have verbAtts -->

 <!-- simply documentType content with verb attributes -->
 <complexType name="documentNoun">
   <choice minOccurs="1"  maxOccurs="unbounded" >
     <element name="document"     type="amf:documentType"/>
   </choice>
   <attributeGroup ref="amf:verbAtts"/>
 </complexType>

 <!-- simply poType content with verb attributes -->
 <complexType name="poNoun">
   <choice minOccurs="1"  maxOccurs="unbounded" >
     <element name="person"       type="amf:poType"/>
     <element name="organization" type="amf:poType"/>
   </choice>
   <attributeGroup ref="amf:verbAtts"/>
 </complexType>

 <complexType name="documentcollectionNoun">
   <choice minOccurs="1"  maxOccurs="unbounded" >
     <element name="document"     type="amf:documentType"/>
     <element name="collection"        type="amf:collectionType"/>
   </choice>
   <attributeGroup ref="amf:verbAtts"/>
 </complexType>

 <!-- simply collectionType content with verb attributes -->
 <complexType name="collectionNoun">
   <choice minOccurs="1"  maxOccurs="unbounded" >
     <element name="document" type="amf:collectionType"/>
   </choice>
   <attributeGroup ref="amf:verbAtts"/>
 </complexType>

  
  
 <!-- noun content type definitions -->

 <!-- document noun content type -->
 <complexType name="documentType">
   <choice minOccurs="0" maxOccurs="unbounded">
     <!--adjectives-->
     <element name="title" type="amf:nameTitleType"/>
     <element name="abstract" type="amf:stringType"/>
     <element name="keywords" type="amf:stringType"/>
     <element name="copyright" type="amf:stringType"/>
     <element name="status" type="amf:stringType"/>
     <element name="comment" type="amf:stringType"/>
     <element name="email" type="amf:stringType"/>
     <element name="date" type="amf:sloppyDateType"/>
     <element name="displaypage" type="amf:urlType"/>
     <element name="citation" type="amf:stringType"/>
     <element name="serial" type="amf:serialType"/>
     <element name="file" type="amf:fileType"/>
     <element name="code" type="amf:idType"/>
     <!--document to document verbs-->
     <element name="iserratumof" type="amf:documentNoun"/>
     <element name="isaddendumof" type="amf:documentNoun"/>
     <element name="isreviewof" type="amf:documentNoun"/>
     <element name="iscommenton" type="amf:documentNoun"/>
     <element name="istranslationof" type="amf:documentNoun"/>
     <element name="isreplacedby" type="amf:documentNoun"/>
     <element name="replaces" type="amf:documentNoun"/>
     <element name="ispartof" type="amf:documentNoun"/>
     <element name="haspart" type="amf:documentNoun"/>
     <element name="isreferencedby" type="amf:documentNoun"/>
     <element name="references" type="amf:documentNoun"/>
     <element name="isversionof" type="amf:documentNoun"/>
     <element name="hasversion" type="amf:documentNoun"/>
     <element name="isformatof" type="amf:documentNoun"/>
     <element name="hasformat" type="amf:documentNoun"/>
     <!--document to po verbs-->
     <element name="hasauthor" type="amf:poNoun"/>
     <element name="haseditor" type="amf:poNoun"/>
     <element name="haspublisher" type="amf:poNoun"/>
     <element name="hastranslator" type="amf:poNoun"/>
     <element name="hassponsor" type="amf:poNoun"/>
     <!--document to collection verbs-->
     <element name="belongsto" type="amf:collectionNoun"/>
   </choice>
   <attributeGroup ref="amf:nounAtts"/>
 </complexType>

 <!-- serial in document noun -->
 <complexType name="serialType">
   <choice minOccurs="0" maxOccurs="unbounded">
     <element name="title" type="amf:nameTitleType"/>
     <element name="date" type="amf:sloppyDateType"/>
     <element name="volume" type="amf:stringType"/>
     <element name="issue" type="amf:stringType"/>
     <element name="firstpage" type="amf:stringType"/>
     <element name="lastpage" type="amf:stringType"/>
   </choice>
   <attributeGroup ref="amf:adjAtts"/>
 </complexType>

 <!-- file in document noun -->
 <complexType name="fileType">
   <choice minOccurs="0" maxOccurs="unbounded">
     <element name="url" type="amf:urlType"/>
     <element name="function" type="amf:stringType"/>
     <element name="format" type="amf:stringType"/>
     <element name="restriction" type="amf:stringType"/>
     <element name="lastpage" type="amf:stringType"/>
   </choice>
   <attributeGroup ref="amf:adjAtts"/>
 </complexType>


 <!-- po noun content type -->
 <complexType name="poType">
   <choice minOccurs="0" maxOccurs="unbounded">
     <!--adjectives-->
     <element name="name" type="amf:nameTitleType"/>
     <element name="shortname" type="amf:stringType"/>
     <element name="date" type="amf:sloppyDateType"/>
     <element name="homepage" type="amf:urlType"/>
     <element name="postal" type="amf:stringType"/>
     <element name="phone" type="amf:stringType"/>
     <element name="fax" type="amf:stringType"/>
     <element name="email" type="amf:stringType"/>
     <element name="code" type="amf:idType"/>
     <!--po to document verbs-->
     <element name="isauthorof" type="amf:documentNoun"/>
     <element name="ispublisherof" type="amf:documentNoun"/>
     <element name="issupervisorof" type="amf:documentNoun"/>
     <element name="istranslatorof" type="amf:documentNoun"/>
     <element name="issponsorof" type="amf:documentNoun"/>
     <!--po to po verbs-->
     <element name="ismemberof" type="amf:poNoun"/>
     <element name="hasmember" type="amf:poNoun"/>
     <element name="ispartof" type="amf:poNoun"/>
     <element name="haspart" type="amf:poNoun"/>
     <element name="isreplacedby" type="amf:poNoun"/>
     <element name="replaces" type="amf:poNoun"/>
     <!--po to collection verbs-->
     <element name="ismaintainerof" type="amf:collectionNoun"/>
     <!--po to document/collection verbs-->
     <element name="iseditorof" type="amf:documentcollectionNoun"/>
   </choice>
   <attributeGroup ref="amf:nounAtts"/>
 </complexType>




 <!-- collection noun content type -->
 <complexType name="collectionType">
   <choice minOccurs="0" maxOccurs="unbounded">
     <!--adjectives-->
     <element name="title" type="amf:nameTitleType"/>
     <element name="shorttitle" type="amf:stringType"/>
     <element name="description" type="amf:typeType"/>
     <element name="homepage" type="amf:urlType"/>
     <element name="type" type="amf:typeType"/>
     <element name="identifier" type="amf:idType"/>
     <!--collection to document verbs-->
     <element name="contains" type="amf:documentNoun"/>
     <!--collection to po verbs-->
     <element name="haseditor" type="amf:poNoun"/>
     <element name="haspublisher" type="amf:poNoun"/>
     <element name="hassponsor" type="amf:poNoun"/>
     <element name="hasmaintainer" type="amf:poNoun"/>
     <!--collection to collection verbs-->
     <element name="isreplacedby" type="amf:collectionNoun"/>
     <element name="replaces" type="amf:collectionNoun"/>
     <element name="ispartof" type="amf:collectionNoun"/>
     <element name="haspart" type="amf:collectionNoun"/>
   </choice>
   <attributeGroup ref="amf:nounAtts"/>
 </complexType>


<complexType name="dmt">
   <simpleContent>
  <restriction base="string">
  <pattern value="\d{4}-\d{2}-\d{2}"/>
  </restriction>
   </simpleContent>
</complexType>


 <complexType name="sloppyDateType">
   <simpleContent>
     <extension base="date">
       <!--event attribute has suggested but not restricted vocab-->
       <attribute name="event" use="optional" type="string"/>
       <attributeGroup ref="amf:adjAtts"/>
     </extension>
   </simpleContent>
 </complexType>    

 <!-- name and title elements may have additional key attrtibute-->
 <complexType name="nameTitleType">
   <simpleContent>
     <extension base="string">
       <attribute name="key" use="optional" type="string"/>
       <attributeGroup ref="amf:adjAtts"/>
     </extension>
   </simpleContent>
 </complexType>
   
 <!-- type element has restricted vocab.-->
 <complexType name="typeType">
   <simpleContent>
     <restriction base="string">
       <pattern value="(classification|journal|proceedings|series)"/>
       <attributeGroup ref="amf:adjAtts"/>
     </restriction>   
   </simpleContent>
 </complexType>

 <!-- URL is a restriction on URI so we should implement this, must look up pattern-->

 <complexType name="urlType">
   <simpleContent>
     <restriction base="anyURI">
       <pattern value=".+://.+/.*"/>
       <attributeGroup ref="amf:adjAtts"/>
     </restriction>   
   </simpleContent>
 </complexType>
 
 <complexType name="idType">
   <simpleContent>
     <extension base="string">
       <!--scheme attribute has suggested but not restricted vocab-->
       <attribute name="scheme" use="optional" type="string"/>
       <attributeGroup ref="amf:adjAtts"/>
     </extension>
   </simpleContent>
 </complexType>
 
 <!-- simply string extended with attributes available for all elements-->
 <complexType name="stringType">
   <simpleContent>
     <extension base="string">
       <attributeGroup ref="amf:adjAtts"/>
     </extension>
   </simpleContent>
 </complexType>
 
 
 <!-- attribute groups for different classes of element -->

 <!-- attribute(s) applicable to all elements -->
 <attributeGroup name="adjAtts">
   <attribute name="lang" use="optional" type="language"/>
 </attributeGroup> 

 <!-- attribute(s) applicable to verbs -->
 <!-- SHOULD these dates be date|month|year? --> 
 <attributeGroup name="verbAtts">
   <attribute name="from" use="optional" type="date"/>
   <attribute name="until" use="optional" type="date"/>
 </attributeGroup> 

 <!-- attribute(s) applicable to nouns, this model should be
      refined so that only non-empty nouns are permitted to
      have the id attribute -->
 <attributeGroup name="nounAtts">
   <attribute name="id" type="string"/> 
   <attribute name="ref" type="string"/>
 </attributeGroup> 
  

</schema>
