DB2 10.5 for Linux, UNIX, and Windows
Whitespace
Whitespace is allowed in most XQuery expressions to improve readability even if whitespace is not part of the syntax for the expression. Whitespace consists of space characters (X'20'), carriage returns (X'0D'), line feeds (X'0A'), and tabs (X'09').
In general, whitespace is not significant in a query, except in the following situations where whitespace is preserved:
- The whitespace is in a string literal.
- The whitespace clarifies an expression by preventing the parser from recognizing two adjacent tokens as one.
- The whitespace is in an element constructor. The boundary-space declaration in the prolog determines whether to preserve or strip whitespace in element constructors.
For example, the following expressions require whitespace for clarity:
- name- name results in an error. The parser recognizes name- as a single QName (qualified name) and returns an error when no operator is found.
- name -name does not result in an error. The parser recognizes the first name as a QName, the minus sign (-) as an operator, and then the second name as another QName.
- name-name does not result in an error. However, the expression is parsed as a single QName because a hyphen (-) is a valid character in a QName.
- The following expressions all result in errors:
- 10 div3
- 10div3