DB2 Version 9.7 for Linux, UNIX, and Windows

Literals

A literal is a direct syntactic representation of an atomic value. DB2® XQuery supports two kinds of literals: numeric literals and string literals.

A numeric literal is an atomic value of type xs:integer, xs:decimal, or xs:double:
  • A numeric literal that contains no decimal point (.) and no e or E character is an atomic value of type xs:integer. For example, 12 is a numeric literal.
  • A numeric literal that contains a decimal point (.), but no e or E character is an atomic value of type xs:decimal. For example, 12.5 is a numeric literal.
  • A numeric literal that contains an e or E character is an atomic value of type xs:double. For example, 125E2 is a numeric literal.

Values of numeric literals are interpreted according to the rules of XML Schema.

A string literal is an atomic value of type xs:string that is enclosed in delimiting single quotation marks (') or double quotation marks ("). String literals can include predefined entity references and character references. For example, the following strings are valid string literals:

"12.5"
"He said, ""Let it be."""
'She said: "Why should I?"'
"Ben & Jerry's"
"€65.50" (: denotes the string €65.50 :)
Tip: To include a single quotation mark within a string literal that is delimited by single quotation marks, specify two adjacent single quotation marks. Similarly, to include a double quotation mark within a string literal that is delimited by double quotation marks, specify two adjacent double quotation marks.

Within a string literal, line endings are normalized according to the rules for XML 1.0 (Third Edition). Any two-character sequence that contains a carriage return (X'0D') followed by a line feed (X'0A') is translated into a single line feed (X'0A'). Any carriage return (X'0D') that is not followed by a line feed (X'0A') is translated into a single line feed (X'0A').

If the value that you want to instantiate has no literal representation, you can use a constructor function or built-in function to return the value. The following functions and constructors return values that have no literal representation: