Tamino XML Server Version 9.7
 —  XQuery 4 Reference Guide  —

Lexical Structure

This document gives an overview of the syntactic structures on the lexical level of Tamino XQuery 4. Any grammar productions use the same form of BNF that is also used in the respective W3C specifications.


Characters

At the character level, Tamino supports the basic multilingual plane (BMP) and plane 16 as defined in Unicode 3.1. You can find detailed information about Unicode support in the section Unicode and Text Retrieval. In Tamino, a character is defined as follows:

Char           ::= #x9 | #xA | #xD | [#x0020-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#10FFFF]
WhitespaceChar ::= #x9 | #xA | #xD | #x20

Top of page

Identifiers

NCName

An NCName is an XML name with the exception that it may not contain the colon character. It is defined in the W3C recommendation Namespaces in XML, section 2. An XML name is defined as Name in the W3C recommendation Extensible Markup Language (XML) 1.0, section 2.4.

QName

A QName is a name that can be qualified with an optional namespace prefix. It is defined in the W3C recommendation Namespaces in XML, section 3.

Top of page

Literals

A literal is the direct syntactic representation of an atomic value. In XQuery, the following literals for strings and numbers are defined:

String Literals

StringLiteral  ::= '"' ( [^"] | '""' )* '"' | "'" ( [^'] | "''" )* "'"

A string literal is a singleton sequence composed of single characters. It has an atomic value of type xs:string that is delimited by single or double quotation marks. If you want to use a single quotation mark in a string literal, either delimit the string literal with double quotation marks, or use two consecutive single quotation marks to represent the single quotation mark. The same applies, mutatis mutandis, to the double quotation mark.

"This is Joe's house."
'This is Joe''s house.'
'I bought a 21" monitor today.'
"He's 5'11" tall."
"He's 5'11"" tall."

Numeric Literals

IntegerLiteral ::= [0-9]+
DecimalLiteral ::= ("." [0-9]+) |  ([0-9]+ "." [0-9]*)
DoubleLiteral  ::= (("." [0-9]+) | ([0-9]+ ("." [0-9]*)?)) ("e" | "E") ("+" | "-")? [0-9]+

A numeric literal is a singleton sequence with an atomic value whose type is determined as follows:

These are valid numeric literals: 42   0.07   .07   3.141   12E04

These are invalid numeric literals: "42"   3,141   0E0A

Boolean Values

You can represent the Boolean values true and false by using the built-in functions fn:true() and fn:false().

Using Constructor Functions

You can use constructor functions for the supported types. The name of the constructor function is normally the same as the name of the type.

Top of page

Comments

A comment in XQuery is defined as follows:

ExprComment ::= "{--" ([^}])* "--}"

So an XQuery comment is delimited by {-- and --} and it must not contain } in between. Comments may even be used within expressions and before or after tokens. However, you can not nest comments. The following query is valid:

declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
{--
      This query uses a Tamino-specific function.
      Multi-line comments are perfectly valid.
--}
for $a in input{-- you should not put any comments here,
but it still works --}()
return tf:getLastModified({-- no error even here --} $a)

You should not place a comment immediately after the opening brace of an enclosed expression, since the character sequence {{ will be interpreted as an escaped {.

Top of page

Other Defined Tokens

The following tokens are also defined in the XQuery grammar.

PredefinedEntityRef  ::= "&"  ("lt" |  "gt" |  "amp" |  "quot" |  "apos") ";"
Variable             ::= "$" QName
CharRef              ::= "&#" ([0-9]+ |  ("x" ([0-9] | [a-f] | [A-F])+)) ";"

Please note that you can use any of the XQuery keywords as the name of an XML element or attribute, if you prepend a colon:

for $a in <for><where let="d">abc</where></for>
return $a/:where[@:let]

Top of page