<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stylesheet
[
<!ENTITY epubtkNS "http://dev.livingreviews.org/epubtk">
<!ENTITY exportNS "/refdb/export">
]>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"
	    attributeFormDefault="qualified"
            version="1.0"
            targetNamespace="&epubtkNS;&exportNS;"
	    xmlns="&epubtkNS;&exportNS;">
  <xsd:annotation>
    <xsd:documentation xml:lang="en">
      export schema for the reference database (refdb) component of ZIM's 
      ePublishingToolkit.
      
      this schema will be publicly available from the schema location
         &epubtkNS;&exportNS;.xsd
      
      $HeadURL$
      $LastChangedBy$
      $LastChangedRevision$
    </xsd:documentation>
  </xsd:annotation>
  
  <xsd:element name="export">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	search results are exported as list of bibliographical records plus 
	meta data about the search which produced the list.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
	<xsd:element ref="query"  minOccurs="0" maxOccurs="1"/>
	<xsd:element ref="record" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="source"        use="required" type="xsd:string"/>
      <xsd:attribute name="journal"       use="optional" type="xsd:string"/>
      <xsd:attribute name="created"       use="required" type="xsd:dateTime"/>
      <xsd:attribute name="schemaVersion" use="required" type="schemaVersionType"/>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:simpleType name="schemaVersionType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	enumeration of version number of this schema which are compatible with the
	current version.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:decimal">
      <xsd:enumeration value="1.0"/>
    </xsd:restriction>
  </xsd:simpleType>
  
  <xsd:element name="query">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	container for input data which made up the query resulting in the list of
	records. the attributes are to be interpreted as follows:
	'totalResults': the total number of records matching the search criteria.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
	<xsd:element ref="input" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="totalResults" use="required" 
		     type="xsd:nonNegativeInteger"/>
      <xsd:attribute name="uri"  use="optional" type="xsd:string" />
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="input">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	element containing one piece of input data, making up the query resulting in
	the list of records.
	values of the name attributes have the following meaning:
	'sortOrder': the criterion to sort the list of matching records.
	'limit':     the number of records to actually retrieve from the db.
	'offset':    the offset within the list of all matching records at which the 
	'limit'-sized is to be cut out.
	'author':    search string entered in the 'author' input field
	'title':     search string entered in the 'title' input field
	'keyword':   search string entered in the 'keyword' input field
	'journal':   search string entered in the 'journal' input field
	'year':      search string entered in the 'year' input field
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:attribute name="name"  use="required" type="xsd:string" />
      <xsd:attribute name="value" use="required" type="xsd:string" />
      <xsd:attribute name="mode"  use="optional" type="xsd:string" />
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="record">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	the container for the various bibliographical data items of a reference
	
	the attribute 'ord' is the ordinal of the record within the result set
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
	<xsd:element ref="bibData" minOccurs="0" maxOccurs="unbounded"/>
	<xsd:element ref="referencedIn" minOccurs="1" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="genre" use="required" type="xsd:string" />
      <xsd:attribute name="id" use="required" type="xsd:string" />
      <xsd:attribute name="ord" use="required" type="xsd:positiveInteger"/>
      <xsd:attribute name="coins" use="optional" type="xsd:string" />
    </xsd:complexType>
  </xsd:element>
  
  <!--
    predefined bibData elements and types 
  -->
  <xsd:element name="referencedIn">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	a container for citation context specific bibliographical data.
	
	the 'pubNo' attribute contains the publication number of the publication
	which cites this record.
	the 'ord' attribute specifies the position of this record within the citing
	article's list of references.
	the 'key' attribute holds the citation key used to refer to the reference in
	the citing article.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
	<xsd:element ref="bibData" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="pubNo" use="required" type="xsd:string"/>
      <xsd:attribute name="ord" use="required" type="xsd:integer"/>
      <xsd:attribute name="key" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>
  
  
  <xsd:element name="bibData" type="bibDataType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	element to hold one atom of bibliographical data such as an author name
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>
  
  <xsd:complexType name="bibDataType" mixed="true">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	the element's content provides the value of the bibliographical data item.
	the 'field' attribute specifies the bibliographical data type of the element.
	the 'type' attribute provides additional information how to interpret the
	content of the element.
	the 'text' attribute provides a LaTeX-string from which the element's content
	was derived.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexContent>
      <xsd:extension base="complexTextType">
	<xsd:attribute name="field" type="xsd:string" use="required"/>
	<xsd:attribute name="type"  type="xsd:string" use="optional"/>
	<xsd:attribute name="tex"   type="xsd:string" use="optional"/>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
  
  <xsd:complexType name="complexTextType" mixed="true">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
	type for bibData element content.
	
	this type of mixed content corresponds to refdb's extended unicode strings
      </xsd:documentation>
    </xsd:annotation>
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="sub" type="xsd:string"/>
      <xsd:element name="sup" type="xsd:string"/>
      <xsd:element name="url" type="xsd:string"/>
    </xsd:choice>
  </xsd:complexType>  
</xsd:schema>
