17.16.1. XSQL Syntax

Properties of each XSQL directives are specified by XML attributes. These attributes are of different types, mostly SQL expressions, calculateable strings, SQL names and lists of names (e.g., name of a database table or a list of columns of a table).

In some cases, SQL expressions are long and it is not convenient to place them into attribute values. Such expressions are written as text content of the XSQL directive element.

SQL expressions.  XSQL allows slightly extended syntax of SQL expressions. If X is a name of page parameter made by xsql:set-page-param then special notation "{@X}" stands for the reference to the parameter value. This notation can be used in any place where a variable name is acceptable. In addition, this notation can be used inside string literals, such a literal is translated into a string concatenation expression; e.g., 'text-head{@X}text-middle{@Y}text-tail' is converted into concat ('text-head', cast ({@X} as varchar), 'text-middle', cast ({@Y} as varchar), 'text-tail') .

Calculateable strings .  Some attribute values are strings like resource URIs or XML names to be used in the output generated by a page. They are usually written 'as is' but they can use "{@X}" notation to insert the value of page parameter into the resulting string. The actual value of a calculateable string is compiled only once even if it appears many times in the XML output of the page.

Names of SQL columns .  Some attributes are not arbitrary SQL expressions but only SQL column names. These names are written 'as is'. Only unqualified names are allowed, not in form 'table.column'. No "{@X}" is allowed for obvious reasons. If SQL name is case-sensitive or contains nonalphabetical characters then the name should be enclosed in double quotes. For readability, use single quotes to surround attribute value to not mix them with possible double quotes used in SQL name. Whitespace characters are not allowed in these names because these will not make proper names of XML elements.

Names of SQL tables .  SQL table names are also written 'as is', with the same rules for double quotes around case-sensitive parts of the name. Both qualified and unqualified names are allowed.

Lists of names of SQL columns .  When the value of attribute lists one or more column names, white space characters or commas delimit column names. The list should be space-delimited like 'COL1 COL2 COL3' or comma-delimited like 'COL1, COL2, COL3' but not a mix of them like 'COL1, COL2 COL3'.