<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en">

    <xsd:annotation>
	<xsd:documentation>
	    Redefines the main XML Query Language schema in XE to validate SQL SELECT
	    statements.

	    XpressEngine is an open source framework for creating your web sites.
	    http://xpressengine.org/

	    File:   tools/xml_select.xsd
	    Author: Adrian Constantin, Arnia Software (adrian.constantin@arnia.ro)
	    Date:   08 mar 2012

	</xsd:documentation>
    </xsd:annotation>

    <xsd:redefine schemaLocation="xml_colassign.xsd">

	<xsd:complexType name="SqlStatementType">
	    <xsd:complexContent>
		<xsd:restriction base="SqlStatementType">
		    <xsd:all>
			<xsd:element name="columns" minOccurs="0" type="ColumnsType" />
			<xsd:element name="tables" minOccurs="1" type="TablesType">
			    <xsd:unique name="table_aliases6">
				<xsd:selector xpath="table" />
				<xsd:field xpath="@alias" />
			    </xsd:unique>
			</xsd:element>
			<xsd:element name="conditions" minOccurs="0" type="ConditionsType" />
			<xsd:element name="groups" minOccurs="0" type="GroupsType">
			    <xsd:unique name="sql_statement_groups">
				<xsd:selector xpath="group" />
				<xsd:field xpath="@column" />
			    </xsd:unique>
			</xsd:element>
			<xsd:element name="navigation" minOccurs="0" type="MainStatementNavigationType" />
			<xsd:element name="index_hint" minOccurs="0" type="IndexHintsType" />
		    </xsd:all>

		    <xsd:attribute name="action" type="selectActionAttributeType" use="required" />

		</xsd:restriction>
	    </xsd:complexContent>
	</xsd:complexType>
    </xsd:redefine>

    <xsd:simpleType name="selectActionAttributeType">
	<xsd:restriction base="actionAttributeType">
	    <xsd:pattern value="[sS][eE][lL][eE][cC][tT]" />
	</xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="query" type="SqlStatementType" />
	
</xsd:schema>
