XML Schema Definition (.xsd) for the XML Query Language for XpressEngine.
XpressEngine is an open source framework for creating your web sites.
http://xpressengine.org/
Author: Adrian Constantin, Arnia Software (adrian.constantin@arnia.ro)
Date: 08 mar 2012
Strictly speaking the term "query language" is improper since the
language also describes the SQL data change statements (INSERT, UPDATE,
DELETE), not only query statements (SELECT).
Although SQL does not distinguish between the syntax of queries and
sub-queries, the XML Query Language identifies 4 query types:
- TableSubquery:
- possibly empty (for a base table given by name)
- abstract (used as a base for the TableType)
- query navigation only (LIMIT, OFFSET)
- ExpressionSubquery
- should include at least a table
- query nagivation only
- Select-list subquery
- should include at least a table
- query nagivation only
- optional alias
- QueryStatement
- should include at least a table
- query navigation and pagination
- 'id' and 'alias' attributes
The XML types hierarchy here shows as follows:
+-- VarNameDefaultType
+-- SortColumnType
|
+-- MainStatementNavigationType
| +-- SimpleQueryNavigationType
|
+-- SqlStatementContentModel (abstract)
| +-- SqlStatementContents (abstract)
| | +-- SqlQueryContents (abstract)
| | | +-- SqlQueryType
| | | +-- ExpressionSubqueryContents
| | | +-- ExpressionSubqueryType
| | +-- SqlStatementType
| |
| +-- SqlTableSubquery (abstract)
| +-- TableType
|
+-- TablesType
|
+-- ColumnType
+-- ColumnsType
|
+-- ConditionType
+-- ConditionsGroupType
+-- ConditionsType
|
+-- GroupType
+-- GroupsType
|
+-- IndexHintType
+-- IndexHintsType
|
+-- pipeAttributeType
+-- dbTargetAttributeType (for db-specific index hints)
+-- HintTypeAttributeType
+-- conditionAttrs (attribute group)
+-- argumentAttrs (query-argument attributes)
The types defined here closely model the behavior of php classes in
classes/xml/xmlquery/**/*.php
Common XSD type for page-row-count/current-page/page-count elements
that are empty and only take a variable name and/or a default as
attributes.
Note that a variable name here means an index in a php array, which
can be any string, not just an [a-zA-Z0-9_]* identifier.
A column name in an ORDER BY clause, given directly by name
(default attribute) or in a variable (var attribute). Either
one of the two attributes is required
XE treats the values "asc" and "desc" as the corresponding SQL
keywords, while all the other values are taken as a parameter
name.
XE sorting and paging for a main-statement query.
Defined as a sequence of choices so that the <index> element
can appear more than once.
Sub-queries do not include a page_count
The base of the SQL query and statement type hierarchy in the XML
query language.
References all possible SQL stetement clauses, while none of them
is declared as required. It is the most generic SQL statement or
query type, though no such SQL statement instantiates it directly.
The <index_hint> element could be allowed to appear multiple
times, in case different hints for different databases will be
allowed by the syntax.
An SQL generic DELETE, UPDATE, INSERT or SELECT statement.
The only common clause for these statements is the table-specification,
for which reason the <tables> element is the only one required by
the syntax
An SQL SELECT statement (used to form sub-queries), represented as
a case of (derived from) a generic SQL statement.
In adition to the the table-specification required by the base
SqlStatementContents type, SQL queries also require a select-list.
This, however is implied to be "*" if missing.
So this type is the same as its base type, but is keep to represent
a SQL query, as opposed to a generic SQL statement.
Content model for <table> element. The <table> element may stand
for one of:
- a base table or view, with only a table name and an optional alias,
- a base table in a join, with the table name and join type attributes,
and the join conditions as content,
- a sub-query, with the contents of a query and the alias attribute.
Note that the current syntax provides no means to express a joined sub-query.
Also the schema definition syntax (XSD) does not allow rules to enforce
exactly one of the above cases in a given element, but rather to only express
the sum (union) of all 3 cases for the <table> element.
There are many more SQL statement types defined by the SQL language, but
currently the above 4 types are supported by the XML Query language in XE.
However certain SQL CREATE statements are also supported in the XML
Schema Language in XE.
Element type for a SQL sub-query in the SELECT list or an expression.
Subqueries directly in the FROM clause are expressed by TableType.
Base type for expression sub-queries (used in <condition>s),
which have no alias.
Columns list for a SELECT, UPDATE, INSERT statement
A column name for a SELECT, UPDATE, INSERT statement.
SELECT statements can have a (simple) expression as the column
name and can have an alias.
For table subqueries use <table query="true">.
A <table> should include the content of a query if the table is a
subquery, that is if it also specifies the query="true" attribute.
A <table> that specifies type="join-type..." for joining with other
tables, should include a <conditions> element with the join
condition(s).
The particular SqlTableSubquery type is defined and needed for the base
type, instead of the general SqlQueryType, becase the contents of a
<table> element can still be empty in case of a base table, while a
subquery always has a FROM clause and a select list.
Only the query="true" value should be used. The false
value is listed here just for completeness.
The query and name attributes should be mutually exclusive;
a sub-query should only use aliases, that is the alias
attribute, instead of name.
With the use of proper quoting, almost any string can be a SQL
(table) name (the exceptions are certain clases of Unicode
characters listed in the SQL standard).
Attributes "type" and "query" should be mutually exclusive, since both
of them require the same <conditions> element in the content for
the <table>, but for different purposes.
The type="inner join" and type="full outer join" cases are not
implemented.
Condition expressions in a WHERE clause. Using the <group>
element is simillar to using parentheses in SQL.
SQL logical operators AND and OR.
Most database systems also support the non-standard operator XOR,
but Transact-SQL just claims the bitwise operator ^ can be used
instead, and does not provide XOR.
Attributes to describe a SQL sub-expression, common to simple subexpression
and to subexpressions with a subquery as operand
The pipe attribute is only optional when there is one condition
in the <conditions> / <group> element.
Certain values have special meaning:
- ipaddress()
- unixtime()
- curdate()
- plus(int count)
- minus(int count)
- multiply(int count)
- sequence()
However these values are only special to XE, while for the schema
definition they are strings.
Element type for sub-expresions with a subquery term.
Currently only conditions of the form:
"column" op var_name
"column" op (sub-query)
are allowed by the XML query language syntax.
The <query> element should only be provided as content if
var or default attributes are not provided.
Groups of conditions in a WHERE clause.
Same as the global ConditionsType, plus the pipe="and|or" attribute.
The pipes attribute is only optional in the (unlikely) case that the
<conditions> element contains only the group.
The GROUP BY clase.
A column name in the GROUP BY clause.
Possible values for the "for" attribute on <index> hint
elements in <index_hint>.
Specifies one of the possible databases supported by XE
(database targets) or ALL.
Currently the 'ALL' value must be uppercase, although the database
types (mysql, mssql, cubrid) are case-insensitive.
Possible index hint types: IGNORE, USE or FORCE.
Only mysql makes effective use of hints to IGNORE an index,
while mssql and CUBRID discard such hints, meaning the index
might still be used.
List of index hints, either for a specific database, or for any database.
Hint to use/not-use a certain index for a certain table in a query or in
a statement.