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

    <xsd:annotation>
	<xsd:documentation>
	    Add a DataChangeStatementTablesType to the main schema definition
	    for XML Query Language in XpressEngine.

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

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

	    The components (clauses) for the SQL data-change statements (INSERT,
	    UPDATE, DELETE) are built upon the general query/statement components
	    defined in xml_query.xsd.

	    Include graph:

	    +-- xml_create_table.xsd
	    +-- xml_query.xsd
		+-- xml_datachange.xsd			    *****
		    +-- xml_colassign.xsd
			+-- xml_insert_generic.xsd
			|   +-- xml_insert.xsd
			|   +-- xml_insert_select.xsd
			|
			+-- xml_select.xsd
			+-- xml_update.xsd
			+-- xml_delete.xsd
			
	    DataChangeStatementTablesType is the type for the &lt;tables&gt;
	    element in the data-change statements. This type only allows one named
	    table as content, which is subject to the INSERT, UPDATE or DELETE.

	    Most SQL implementations do allow multi-table UPDATE and DELETE
	    statements and the XML Query language can express multi-table UPDATEs.

	    Also adds the priority attribute to SqlStatementType, used by the
	    data-change statements.
	</xsd:documentation>
    </xsd:annotation>

    <!-- include the main schema definition for XML Query Language -->
    <xsd:redefine schemaLocation="xml_query.xsd">

	<xsd:complexType name="SqlStatementType">
	    <xsd:complexContent>
		<xsd:extension base="SqlStatementType">
		    <xsd:attribute name="priority" type="priorityAttributeType" />
		</xsd:extension>
	    </xsd:complexContent>
	</xsd:complexType>

    </xsd:redefine>

    <xsd:simpleType name="priorityAttributeType">
	<xsd:restriction base="xsd:string">
	    <xsd:enumeration value="LOW" />
	    <xsd:enumeration value="HIGH" />
	</xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="DataChangeStatementTableType">
	<xsd:annotation>
	    <xsd:documentation>
		A named table only, no subquery/alias/join-type ...
	    </xsd:documentation>
	</xsd:annotation>

	<xsd:complexContent>
	    <xsd:restriction base="TableType">
		<xsd:all />

		<xsd:attribute name="query" use="prohibited" />
		<xsd:attribute name="type" use="prohibited" />
		<xsd:attribute name="alias" use="prohibited" />
		<xsd:attribute name="name" type="xsd:string" use="required" />
	    </xsd:restriction>
	</xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="DataChangeStatementTablesType">
	<xsd:annotation>
	    <xsd:documentation>
		A list of exactly one named table.
	    </xsd:documentation>
	</xsd:annotation>

	<xsd:complexContent>
	    <xsd:restriction base="TablesType">
		<xsd:sequence>
		    <xsd:element name="table" type="DataChangeStatementTableType" minOccurs="1" />
		</xsd:sequence>
	    </xsd:restriction>
	</xsd:complexContent>
    </xsd:complexType>

</xsd:schema>
