<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Markus Doering (BGBM) -->
<!-- $Id: conmap.xsd,v 1.6 2004/12/23 12:33:09 markus Exp $ -->
<!-- A schema to create configuration files for database providers to link their arbitrary database to the generic pywrapper of BioCASE -->
<!-- Authors: M.Doering, A.Guentsch, A.Hahn -->
<!-- Botanic Museum and Botanical Garden Berlin-Dahlem -->
<xs:schema targetNamespace="http://www.biocase.org/schemas/conceptmapping/2.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.biocase.org/schemas/conceptmapping/2.1" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="conceptMapping">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="metadata">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="generated" minOccurs="0">
								<xs:complexType>
									<xs:attribute name="when" type="xs:dateTime" use="required"/>
									<xs:attribute name="by" type="xs:string" use="required"/>
								</xs:complexType>
							</xs:element>
							<xs:element name="modified" minOccurs="0">
								<xs:complexType>
									<xs:attribute name="when" type="xs:dateTime" use="required"/>
									<xs:attribute name="by" type="xs:string" use="required"/>
								</xs:complexType>
							</xs:element>
							<xs:element name="name">
								<xs:complexType>
									<xs:simpleContent>
										<xs:extension base="xs:string">
											<xs:attribute name="version" type="xs:string" use="optional"/>
											<xs:attribute name="acronym" type="xs:string" use="optional"/>
										</xs:extension>
									</xs:simpleContent>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="settings">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="omitNamespaces" type="xs:boolean" default="false"/>
							<xs:element name="rootTableAlias" type="xs:string">
								<xs:annotation>
									<xs:documentation>The table-alias in your DB as given in the ProviderConfig preferences that acts as a "root" table for all records. This table needs to have one unique identifier (primary key). Important to build dynamic SQL and count records.</xs:documentation>
								</xs:annotation>
							</xs:element>
							<xs:element name="staticTableAlias" minOccurs="0" maxOccurs="unbounded">
								<xs:annotation>
									<xs:documentation>A table-alias that is always included in the output via a FULL OUTER JOIN. Dont enter more than 1 record, as this will blow up your resulting XML.</xs:documentation>
								</xs:annotation>
								<xs:complexType>
									<xs:simpleContent>
										<xs:extension base="xs:string"/>
									</xs:simpleContent>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="recordIdentifier" type="pathType" maxOccurs="unbounded">
					<xs:annotation>
						<xs:documentation>The xpath to an element used as the Identifier for the basic record of the concept. E.g Units for ABCD, or maybe names for other concepts. Important for the count method. Maybe several xpaths for schemas without a single root records element.</xs:documentation>
					</xs:annotation>
				</xs:element>
				<xs:element name="dataElement">
					<xs:annotation>
						<xs:documentation>An element (inherits attribute properties)</xs:documentation>
					</xs:annotation>
					<xs:complexType>
						<xs:complexContent>
							<xs:extension base="elementType"/>
						</xs:complexContent>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:complexType name="attributeType">
		<xs:sequence>
			<xs:element name="vocabulary" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Controlled vocabulary for this element. You can provide an optional spelling for the equivalent term used in your database so you dont have to convert them.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:sequence>
						<xs:element name="term" maxOccurs="unbounded">
							<xs:complexType>
								<xs:sequence>
									<xs:element name="dbTerm" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
								</xs:sequence>
								<xs:attribute name="schemaTerm" type="xs:string" use="required"/>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="filterRecords" type="filterType" minOccurs="0"/>
			<xs:element name="mapping" minOccurs="0" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Set this element for every mapping you wish to do. A mapping can consist of static values (literals), db attributes or a concatenation of them. If you dont want to allow searches on this attribute (or your DB cannot search on it as with NTEXT fields in SQL Server), set the flag "nosearch" to 1 or TRUE. This is automatically done for literals and concatenated mappings.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:complexContent>
						<xs:extension base="mappingType">
							<xs:sequence minOccurs="0">
								<xs:element name="if" type="filterType" minOccurs="0">
									<xs:annotation>
										<xs:documentation>An optional conditional clause. If this is set, the mapping will only be used if the condition expressed here is true. Based on the protocol syntax for filter, this uses a limited subset of a protocol filter with no logical nestings. </xs:documentation>
									</xs:annotation>
								</xs:element>
							</xs:sequence>
						</xs:extension>
					</xs:complexContent>
				</xs:complexType>
			</xs:element>
			<xs:element name="annot" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>The annotation / documentation of this concept.</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="ext" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Any other substructure as need for other applications, eg the configuration tool.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:sequence minOccurs="0">
						<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="path" type="pathType" use="required"/>
		<xs:attribute name="name" type="xs:string" use="required"/>
		<xs:attribute name="fullname" type="xs:string" use="optional"/>
		<xs:attribute name="w3cType" type="xs:string" use="optional"/>
		<xs:attribute name="min" type="xs:nonNegativeInteger" use="required"/>
	</xs:complexType>
	<xs:complexType name="elementType">
		<xs:annotation>
			<xs:documentation>Defining a potential XML element. Attribute max should be set to -1 for unbounded elements. The namespace attribute defines the namespace used for output of the element and its subelements until another namespace is encountered.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="attributeType">
				<xs:sequence>
					<xs:element name="attributes" minOccurs="0">
						<xs:complexType>
							<xs:sequence>
								<xs:element name="attribute" type="attributeType" maxOccurs="unbounded"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
					<xs:element name="childElements" minOccurs="0">
						<xs:complexType>
							<xs:sequence>
								<xs:element name="dataElement" type="elementType" maxOccurs="unbounded"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
				</xs:sequence>
				<xs:attribute name="max" type="xs:integer" use="required"/>
				<xs:attribute name="choiceNodeId" type="xs:int" use="optional"/>
				<xs:attribute name="choiceElemId" type="xs:int" use="optional"/>
				<xs:attribute name="namespace" type="xs:anyURI" use="optional"/>
				<xs:attribute name="preferredChoiceFlag" type="xs:boolean" use="optional"/>
				<xs:attribute name="dontRepeat" type="xs:boolean" use="optional"/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="dbAttributeType">
		<xs:attribute name="tablealias" type="xs:string" use="required"/>
		<xs:attribute name="attribute" type="xs:string" use="required"/>
		<xs:attribute name="type" use="optional">
			<xs:simpleType>
				<xs:restriction base="xs:NMTOKEN">
					<xs:enumeration value="integer"/>
					<xs:enumeration value="float"/>
					<xs:enumeration value="date"/>
					<xs:enumeration value="text"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="nosearch" type="xs:boolean" use="optional"/>
	</xs:complexType>
	<xs:complexType name="mappingType">
		<xs:choice maxOccurs="unbounded">
			<xs:annotation>
				<xs:documentation>You can concatenate any number of literals of dbAttributes to be treated as a single mapping.</xs:documentation>
			</xs:annotation>
			<xs:element name="dbAttribute" type="dbAttributeType">
				<xs:annotation>
					<xs:documentation>Set this element for every attribute in your database that should be part of a single mapping to an XML element. The type of the attribute in the DB must be given if it differs from "text". </xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="literal">
				<xs:annotation>
					<xs:documentation>A fixed literal value taken from the attribute 'value' of this element.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:attribute name="value"/>
				</xs:complexType>
			</xs:element>
			<xs:element name="TotalMatchedRecords">
				<xs:annotation>
					<xs:documentation>Inserts the number of all records that matched the query in the database. Does not test for validity of records.</xs:documentation>
				</xs:annotation>
				<xs:complexType/>
			</xs:element>
		</xs:choice>
	</xs:complexType>
	<xs:complexType name="filterType">
		<xs:annotation>
			<xs:documentation>Based on the protocol syntax for filter encodings, this uses a limited subset of a protocol filter with no logical nestings. </xs:documentation>
		</xs:annotation>
		<xs:choice>
			<xs:annotation>
				<xs:documentation>you can only chose between an OR or AND combination of comparisons.</xs:documentation>
			</xs:annotation>
			<xs:group ref="COPGroup"/>
			<xs:element name="and">
				<xs:complexType>
					<xs:complexContent>
						<xs:extension base="COPListType"/>
					</xs:complexContent>
				</xs:complexType>
			</xs:element>
			<xs:element name="or" type="COPListType"/>
		</xs:choice>
	</xs:complexType>
	<xs:complexType name="COPListType">
		<xs:sequence maxOccurs="unbounded">
			<xs:group ref="COPGroup"/>
		</xs:sequence>
	</xs:complexType>
	<xs:group name="COPGroup">
		<xs:choice>
			<xs:element name="equals" type="comparisonType"/>
			<xs:element name="notEquals" type="comparisonType"/>
			<xs:element name="lessThan" type="comparisonType"/>
			<xs:element name="lessThanOrEquals" type="comparisonType"/>
			<xs:element name="greaterThan" type="comparisonType"/>
			<xs:element name="greaterThanOrEquals" type="comparisonType"/>
			<xs:element name="in">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="value" type="xs:string" maxOccurs="unbounded"/>
					</xs:sequence>
					<xs:attribute name="tablealias" type="xs:string" use="required"/>
					<xs:attribute name="attribute" type="xs:string" use="required"/>
					<xs:attribute name="type" use="optional">
						<xs:simpleType>
							<xs:restriction base="xs:NMTOKEN">
								<xs:enumeration value="integer"/>
								<xs:enumeration value="float"/>
								<xs:enumeration value="date"/>
								<xs:enumeration value="text"/>
							</xs:restriction>
						</xs:simpleType>
					</xs:attribute>
				</xs:complexType>
			</xs:element>
		</xs:choice>
	</xs:group>
	<xs:complexType name="comparisonType">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="tablealias" type="xs:string" use="required"/>
				<xs:attribute name="attribute" type="xs:string" use="required"/>
				<xs:attribute name="type" use="optional">
					<xs:simpleType>
						<xs:restriction base="xs:NMTOKEN">
							<xs:enumeration value="integer"/>
							<xs:enumeration value="float"/>
							<xs:enumeration value="date"/>
							<xs:enumeration value="string"/>
							<xs:enumeration value="unicode"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:simpleType name="urlType">
		<xs:annotation>
			<xs:documentation>A simpleType to represent a URL that does a pattern match to verify a full URL without whitespace.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="http://[^ ]*[^., \n\t>&quot;]"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="pathType">
		<xs:annotation>
			<xs:documentation>A simpleType to represent an xpath-type used for querying.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="(/[a-zA-Z0-9_\-]+)*(\[@[a-zA-Z0-9_\-]+\])?"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

