<?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.12 2003/11/17 16:38:49 m.doering 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.0" xmlns="http://www.biocase.org/schemas/conceptmapping/2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="conceptMapping">
		<xs:complexType>
			<xs:sequence>
				<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: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="filterRecordsWhere" minOccurs="0">
				<xs:annotation>
					<xs:documentation>An optional conditional clause independent of a mapping. If this is set, the result recordset taken from the database will be filtered for this CMF element and all its children. Only records with a true condition expressed here are passed on. Based on the protocol syntax for filter, this uses initially only a very limited subset of a protocol filter. Maybe extended in the future while keeping backwards compatability.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:choice>
						<xs:element name="equals" type="comparisonType"/>
						<xs:element name="notEquals" type="comparisonType"/>
						<xs:element name="in">
							<xs:complexType>
								<xs:complexContent>
									<xs:extension base="mappingType">
										<xs:sequence>
											<xs:element name="value" type="xs:string" maxOccurs="unbounded"/>
										</xs:sequence>
									</xs:extension>
								</xs:complexContent>
							</xs:complexType>
						</xs:element>
					</xs:choice>
				</xs:complexType>
			</xs:element>
			<xs:element name="mapDB" minOccurs="0" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Set this element for every attribute in your database that should be mapped to an XML element. The type of the attribute in the DB must be given if it differs from "unicode". 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.</xs:documentation>
				</xs:annotation>
				<xs:complexType>
					<xs:complexContent>
						<xs:extension base="mappingType">
							<xs:sequence minOccurs="0">
								<xs:element name="if" 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 initially only a very limited subset of a protocol filter. Maybe extended in the future while keeping backwards compatability.</xs:documentation>
									</xs:annotation>
									<xs:complexType>
										<xs:choice>
											<xs:element name="equals" type="comparisonType"/>
											<xs:element name="notEquals" type="comparisonType"/>
											<xs:element name="in">
												<xs:complexType>
													<xs:complexContent>
														<xs:extension base="mappingType">
															<xs:sequence>
																<xs:element name="value" type="xs:string" maxOccurs="unbounded"/>
															</xs:sequence>
														</xs:extension>
													</xs:complexContent>
												</xs:complexType>
											</xs:element>
										</xs:choice>
									</xs:complexType>
								</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"/>
					</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="dontRepeat" type="xs:boolean" use="optional"/>
				<xs:attribute name="choiceNodeId" type="xs:int" use="optional"/>
				<xs:attribute name="choiceElemId" type="xs:int" use="optional"/>
				<xs:attribute name="preferredChoiceElemId" type="xs:int" use="optional"/>
				<xs:attribute name="namespace" type="xs:anyURI" use="optional"/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="mappingType">
		<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:attribute name="nosearch" type="xs:boolean" use="optional"/>
	</xs:complexType>
	<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>
