<?xml version="1.0"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Markus Doering (BGBM) -->
<!-- edited with XML Spy v4.2 U (http://www.xmlspy.com) by Markus Doering (BGBM, FU-Berlin) -->
<!-- Authors: M.Doering, A.Guentsch, A.Hahn -->
<!-- BioCASE protocol schema version 1.31 changes: capabilities response was changed: SupportedSchemas instead of SupportedSchema to adjust to pywrapper implementation. Capabilities concept wit optional attributes. Search filter optional, scan can contain filters. -->
<!-- BioCASE protocol schema version 1.2 changes: capabilities response was changed to include all existing DB concepts for every supported schema. Introduction of isNull and isNotNull comparison operators based on a new type unaryCOP, which is the same as simpleCOP but does not allow an element to contain data. -->
<!-- BioCASE protocol schema version 1.1 based on DiGIR -->
<!-- Botanic Museum and Botanical Garden Berlin-Dahlem -->
<xsd:schema targetNamespace="http://www.biocase.org/schemas/protocol/1.3" xmlns="http://www.biocase.org/schemas/protocol/1.3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:complexType name="header">
		<xsd:annotation>
			<xsd:documentation>Inline request header used in request and response documents.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="version" minOccurs="0" maxOccurs="unbounded">
				<xsd:annotation>
					<xsd:documentation>Version of the software running, as in beta3 or release 1.0.</xsd:documentation>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:string">
							<xsd:attribute name="software" type="xsd:string" use="optional"/>
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="sendTime" type="xsd:dateTime">
				<xsd:annotation>
					<xsd:documentation>The time the request or response is being sent.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
			<xsd:element name="source">
				<xsd:annotation>
					<xsd:documentation>The source of the request or response.  For search requests, it is the IP of the original requestor.  For all other requests and for responses, its the accessPoint of the host machine.  The optional resource attibute should be set to the provider's resource code, in necessary.</xsd:documentation>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:string">
							<xsd:attribute name="resource" type="xsd:string" use="optional"/>
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="destination" minOccurs="0" maxOccurs="unbounded">
				<xsd:annotation>
					<xsd:documentation>The destination of the request or response.  This will be the provider accesspoint for requests and the portal for responses.  The optional resource attibute should be set to the provider's resource code, in necessary.</xsd:documentation>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:string">
							<xsd:attribute name="resource" type="xsd:string" use="optional"/>
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="type">
				<xsd:annotation>
					<xsd:documentation>Type of operation being requested or being responded to.</xsd:documentation>
				</xsd:annotation>
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="search"/>
						<xsd:enumeration value="capabilities"/>
						<xsd:enumeration value="error"/>
						<xsd:enumeration value="scan"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:simpleType name="urlType">
		<xsd:annotation>
			<xsd:documentation>A simpleType to represent a URL that does a pattern match to verify a full URL without whitespace.</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="http://[^ ]*[^., \n\t>&quot;]"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="emailType">
		<xsd:annotation>
			<xsd:documentation>A simpleType to represent an email address.</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="([a-zA-Z0-9_\-\.\+]+)@([a-zA-Z0-9\-\.]+)"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="pathType">
		<xsd:annotation>
			<xsd:documentation>A simpleType to represent an xpath-type used for querying.</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="(/[a-zA-Z0-9_\-]+)+(\[@[a-zA-Z0-9_\-]+\])?"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:element name="request">
		<xsd:annotation>
			<xsd:documentation>Request message format.  Must always contain and header and may or maynot contain a payload, based on the type of request being made.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="header" type="header"/>
				<xsd:choice minOccurs="0">
					<xsd:element name="search" type="searchOperationType"/>
					<xsd:element name="scan" type="scanType"/>
				</xsd:choice>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:complexType name="searchOperationType">
		<xsd:annotation>
			<xsd:documentation>A search operation, specifying query conditions and result details.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="requestFormat" type="xsd:anyURI"/>
			<xsd:element name="responseFormat">
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:anyURI">
							<xsd:attribute name="start" type="xsd:nonNegativeInteger" default="0"/>
							<xsd:attribute name="limit" type="xsd:nonNegativeInteger" default="10"/>
							<xsd:attribute name="transformation" type="xsd:anyURI" use="optional"/>
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="filter" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>Essentially, a representation of the "where" clause.</xsd:documentation>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:choice>
						<xsd:element ref="COP"/>
						<xsd:element ref="LOP"/>
					</xsd:choice>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="count" type="xsd:boolean" default="false"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:complexType name="scanType">
		<xsd:sequence>
			<xsd:element name="requestFormat" type="xsd:anyURI"/>
			<xsd:element name="concept" type="pathType"/>
			<xsd:element name="filter" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>Essentially, a representation of the "where" clause.</xsd:documentation>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:choice>
						<xsd:element ref="COP"/>
						<xsd:element ref="LOP"/>
					</xsd:choice>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name="COP" abstract="true">
		<xsd:annotation>
			<xsd:documentation>An abstract element provided as a base to group all comparitive operator elements.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="unaryCOP" abstract="true" substitutionGroup="COP"/>
	<xsd:element name="simpleCOP" abstract="true" substitutionGroup="COP"/>
	<xsd:element name="multiCOP" abstract="true" substitutionGroup="COP"/>
	<xsd:complexType name="unaryCOP">
		<xsd:attribute name="path" type="pathType" use="required"/>
	</xsd:complexType>
	<xsd:complexType name="simpleCOP">
		<xsd:simpleContent>
			<xsd:extension base="xsd:string">
				<xsd:attribute name="path" type="pathType" use="required"/>
			</xsd:extension>
		</xsd:simpleContent>
	</xsd:complexType>
	<xsd:complexType name="multiCOP">
		<xsd:sequence>
			<xsd:element name="value" type="xsd:string" maxOccurs="unbounded"/>
		</xsd:sequence>
		<xsd:attribute name="path" type="pathType" use="required"/>
	</xsd:complexType>
	<xsd:element name="equals" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The equals (=) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="notEquals" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The not equals (!=) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="lessThan" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The less than (&lt;) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="lessThanOrEquals" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The less than or equals (&lt;=) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="greaterThan" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The greater than (>) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="greaterThanOrEquals" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The greater than or equals (>=) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="isNull" type="unaryCOP" substitutionGroup="unaryCOP">
		<xsd:annotation>
			<xsd:documentation>compares if concept(xpath) is null. use equal element to compare for empty strings ''.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="isNotNull" type="unaryCOP" substitutionGroup="unaryCOP">
		<xsd:annotation>
			<xsd:documentation>compares if concept(xpath) is not null. use equal element to compare for empty strings ''.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="like" type="simpleCOP" substitutionGroup="simpleCOP">
		<xsd:annotation>
			<xsd:documentation>The like (LIKE) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="in" type="multiCOP" substitutionGroup="multiCOP">
		<xsd:annotation>
			<xsd:documentation>The in (IN) comparator element.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="LOP" abstract="true">
		<xsd:annotation>
			<xsd:documentation>A logical operator clause.  This is an abstract element to be substituted by concrete logical operator elements.</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:element name="unaryLOP" abstract="true" substitutionGroup="LOP"/>
	<xsd:element name="binaryLOP" abstract="true" substitutionGroup="LOP"/>
	<xsd:complexType name="unaryLOPType">
		<xsd:choice>
			<xsd:element ref="COP"/>
			<xsd:element ref="LOP"/>
		</xsd:choice>
	</xsd:complexType>
	<xsd:complexType name="binaryLOPType">
		<xsd:choice minOccurs="2" maxOccurs="2">
			<xsd:element ref="COP"/>
			<xsd:element ref="LOP"/>
		</xsd:choice>
	</xsd:complexType>
	<xsd:element name="not" substitutionGroup="unaryLOP">
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="unaryLOPType">
					<xsd:attribute name="syntax" type="xsd:string" fixed="not"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="and" substitutionGroup="binaryLOP">
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="binaryLOPType">
					<xsd:attribute name="syntax" type="xsd:string" fixed="and"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="or" substitutionGroup="binaryLOP">
		<xsd:annotation>
			<xsd:documentation>The or logical operator.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="binaryLOPType">
					<xsd:attribute name="syntax" type="xsd:string" fixed="or"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="response">
		<xsd:annotation>
			<xsd:documentation>Response message format.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="header" type="header"/>
				<xsd:element name="content" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>The content of the response, as in the search results or status information.  We use xsd:any because the content will be some XML that we do not know yet or that we will not know.  The element is optional because certain types of request deliver all their response by way of the diagnostics. Optionally (for all search and scan requests) the "recordCount" attribute should be set. It counts all records delivered in the XML document, while totalSearchHits refers to the records in the database that matched the request. If a DB record could not be converted to a valid XML "record", it might have been dropped completely and shows up in the attribute "recordDropped".</xsd:documentation>
					</xsd:annotation>
					<xsd:complexType>
						<xsd:sequence>
							<xsd:any maxOccurs="unbounded"/>
						</xsd:sequence>
						<xsd:attribute name="recordStart" type="xsd:integer" use="optional"/>
						<xsd:attribute name="recordCount" type="xsd:integer" use="optional"/>
						<xsd:attribute name="recordDropped" type="xsd:integer" use="optional"/>
						<xsd:attribute name="totalSearchHits" type="xsd:integer" use="optional"/>
					</xsd:complexType>
				</xsd:element>
				<xsd:element name="diagnostics" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>The diagnostics element can contain many diagnostic pieces of information.  Should the possible diagnostic codes/messages be defined more granularly in a seperate XML Schema?</xsd:documentation>
					</xsd:annotation>
					<xsd:complexType>
						<xsd:sequence>
							<xsd:element name="diagnostic" type="diagnostic" maxOccurs="unbounded"/>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="capabilities">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="SupportedSchemas" minOccurs="0" maxOccurs="unbounded">
					<xsd:annotation>
						<xsd:documentation>holds the namespace of a supported schema. Uses attributes to indicate allowed usage for requests and/or responses.</xsd:documentation>
					</xsd:annotation>
					<xsd:complexType>
						<xsd:sequence minOccurs="0">
							<xsd:element name="Concept" maxOccurs="unbounded">
								<xsd:annotation>
									<xsd:documentation>holds a xpath expression that is mapped to the providers DB. Repeatable to become a list of all mapped xpaths.</xsd:documentation>
								</xsd:annotation>
								<xsd:complexType>
									<xsd:simpleContent>
										<xsd:extension base="xsd:string">
											<xsd:attribute name="searchable" type="xsd:boolean" use="optional" default="true"/>
											<xsd:attribute name="datatype" type="xsd:string" use="optional"/>
										</xsd:extension>
									</xsd:simpleContent>
								</xsd:complexType>
							</xsd:element>
						</xsd:sequence>
						<xsd:attribute name="namespace" type="xsd:anyURI" use="required"/>
						<xsd:attribute name="request" type="xsd:boolean" use="required"/>
						<xsd:attribute name="response" type="xsd:boolean" use="required"/>
					</xsd:complexType>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="scan">
		<xsd:annotation>
			<xsd:documentation>The scan result for a scan response.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="value" type="xsd:string" maxOccurs="unbounded">
					<xsd:annotation>
						<xsd:documentation>list of distinct values.</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:complexType name="diagnostic">
		<xsd:simpleContent>
			<xsd:extension base="xsd:string">
				<xsd:attribute name="code" type="xsd:string"/>
				<xsd:attribute name="severity" default="info">
					<xsd:simpleType>
						<xsd:restriction base="xsd:string">
							<xsd:enumeration value="debug"/>
							<xsd:enumeration value="info"/>
							<xsd:enumeration value="warn"/>
							<xsd:enumeration value="error"/>
							<xsd:enumeration value="fatal"/>
						</xsd:restriction>
					</xsd:simpleType>
				</xsd:attribute>
			</xsd:extension>
		</xsd:simpleContent>
	</xsd:complexType>
</xsd:schema>
