<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://incubator.apache.org/uima/regex"
            xmlns="http://incubator.apache.org/uima/regex" elementFormDefault="qualified">
	<!--
		* Licensed to the Apache Software Foundation (ASF) under one
		* or more contributor license agreements.  See the NOTICE file
		* distributed with this work for additional information
		* regarding copyright ownership.  The ASF licenses this file
		* to you under the Apache License, Version 2.0 (the
		* "License"); you may not use this file except in compliance
		* with the License.  You may obtain a copy of the License at
		* 
		*   http://www.apache.org/licenses/LICENSE-2.0
		* 
		* Unless required by applicable law or agreed to in writing,
		* software distributed under the License is distributed on an
		* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
		* KIND, either express or implied.  See the License for the
		* specific language governing permissions and limitations
		* under the License.
	-->

  <xs:element name="conceptSet">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="variables" minOccurs="0" maxOccurs="1" />
		<xs:element ref="concept" minOccurs="0"	maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="variables">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="variable" minOccurs="0" maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="variable">
	<xs:complexType>
	  <xs:attribute name="name" type="xs:string" use="required" />
	  <xs:attribute name="value" type="xs:string" use="required" />
	</xs:complexType>
  </xs:element>

  <xs:element name="concept">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="rules" minOccurs="1" maxOccurs="1" />
		<xs:element ref="createAnnotations" minOccurs="1" maxOccurs="1" />
	  </xs:sequence>
	  <xs:attribute name="name" type="xs:string" use="optional" />
	  <xs:attribute name="processAllRules" type="xs:boolean" use="optional" default="false" />
	</xs:complexType>
  </xs:element>

  <xs:element name="createAnnotations">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="annotation" minOccurs="1" maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="rules">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="rule" minOccurs="1" maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="rule">
	<xs:complexType>
	  <xs:all>
		<xs:element ref="matchTypeFilter" minOccurs="0"	maxOccurs="1" />
		<xs:element ref="updateMatchTypeAnnotation" minOccurs="0" maxOccurs="1" />
		<xs:element ref="ruleExceptions" minOccurs="0" maxOccurs="1" />
	  </xs:all>
	  <xs:attribute name="regEx" type="xs:string" use="required" />
	  <xs:attribute name="matchStrategy" use="required">
	    <xs:simpleType>
		  <xs:restriction base="xs:string">
		    <xs:enumeration value="matchFirst" />
			<xs:enumeration value="matchAll" />
			<xs:enumeration value="matchComplete" />
		  </xs:restriction>
		</xs:simpleType>
	  </xs:attribute>
	  <xs:attribute name="matchType" type="xs:string" use="required" />
	  <xs:attribute name="featurePath" type="xs:string" use="optional" />
	  <xs:attribute name="ruleId" type="xs:string" use="optional" />
	  <xs:attribute name="confidence" type="xs:decimal"	use="optional" />
	</xs:complexType>
  </xs:element>

  <xs:element name="matchTypeFilter">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="feature" minOccurs="0"	maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="ruleExceptions">
	<xs:complexType>
	  <xs:sequence>
	    <xs:element ref="exception" minOccurs="0" maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="exception">
	<xs:complexType>
	  <xs:simpleContent>
		<xs:extension base="xs:string">
		  <xs:attribute name="matchType" type="xs:string" use="required" />
		</xs:extension>
	  </xs:simpleContent>
	</xs:complexType>
  </xs:element>

  <xs:element name="feature">
	<xs:complexType>
	  <xs:simpleContent>
		<xs:extension base="xs:string">
		  <xs:attribute name="featurePath" type="xs:string" use="required" />
		</xs:extension>
	  </xs:simpleContent>
	</xs:complexType>
  </xs:element>

  <xs:element name="annotation">
	<xs:complexType>
	  <xs:sequence>
		<xs:element ref="begin" minOccurs="1" maxOccurs="1" />
		<xs:element ref="end" minOccurs="1" maxOccurs="1" />
		<xs:element ref="setFeature" minOccurs="0" maxOccurs="unbounded" />
	  </xs:sequence>
	  <xs:attribute name="id" type="xs:string" use="optional" />
	  <xs:attribute name="type" type="xs:string" use="required" />
	  <xs:attribute name="validate" type="xs:string" use="optional" />
	</xs:complexType>
  </xs:element>

  <xs:element name="updateMatchTypeAnnotation">
	<xs:complexType>
	  <xs:sequence>
	    <xs:element ref="setFeature" minOccurs="0" maxOccurs="unbounded" />
	  </xs:sequence>
	</xs:complexType>
  </xs:element>

  <xs:element name="begin">
	<xs:complexType>
	  <xs:attribute name="group" use="required" type="xs:integer"/>
	  <xs:attribute name="location" use="optional" default="start">
	    <xs:simpleType>
	      <xs:restriction base="xs:string">
		    <xs:enumeration value="start" />
		    <xs:enumeration value="end" />
		  </xs:restriction>
	    </xs:simpleType>
	  </xs:attribute>
	</xs:complexType>
  </xs:element>

  <xs:element name="end">
	<xs:complexType>
	  <xs:attribute name="group" use="required" type="xs:integer"/>
	  <xs:attribute name="location" use="optional" default="end">
		<xs:simpleType>
		  <xs:restriction base="xs:string">
		    <xs:enumeration value="start" />
			<xs:enumeration value="end" />
		  </xs:restriction>
		</xs:simpleType>
	  </xs:attribute>
	</xs:complexType>
  </xs:element>

  <xs:element name="setFeature">
	<xs:complexType>
	  <xs:simpleContent>
		<xs:extension base="xs:string">
		  <xs:attribute name="name" type="xs:string" use="required" />
		  <xs:attribute name="type" use="required">
		    <xs:simpleType>
			  <xs:restriction base="xs:string">
			    <xs:enumeration value="String" />
				<xs:enumeration value="Integer" />
				<xs:enumeration value="Float" />
				<xs:enumeration value="Reference" />
				<xs:enumeration value="Confidence" />
				<xs:enumeration value="RuleId" />
			  </xs:restriction>
			</xs:simpleType>
		  </xs:attribute>
		  <xs:attribute name="normalization" use="optional">
		    <xs:simpleType>
			  <xs:restriction base="xs:string">
			    <xs:enumeration value="Custom" />
				<xs:enumeration value="ToLowerCase" />
				<xs:enumeration value="ToUpperCase" />
				<xs:enumeration value="Trim" />
			  </xs:restriction>
			</xs:simpleType>
		  </xs:attribute>
		  <xs:attribute name="class" type="xs:string" use="optional" />
		</xs:extension>
	  </xs:simpleContent>
	</xs:complexType>
  </xs:element>
</xs:schema>
