Comments in XQuery
Comments are allowed in an XQuery expression, wherever nonessential whitespace is allowed. Comments do not affect expression processing.
A comment is a string that is delimited by the symbols
(:
and :)
.
The following example is a comment in XQuery:(: This is a comment. It makes code easier to understand. :)
The following general rules apply to using comments in XQuery:
- Comments can be used wherever nonessential whitespace is allowed. Nonessential whitespace is whitespace that is not part of the syntax of an XQuery expression.
- Comments can nest within each other, but each nested comment must
have open and close delimiters,
(:
and:)
.
The following examples illustrate legal comments and comments that result in errors:
(: is this a comment? ::)
is a legal comment.(: is this a comment? ::) or an error? :)
results in an error because there is an unbalanced nesting of the symbols(:
and:)
.(: commenting out a (: comment :) may be confusing, but often helpful :)
is a legal comment because a balanced nesting of comments is allowed."this is just a string :)"
is a legal expression.(: "this is just a string :)" :)
results in a syntax error. Likewise,"this is another string (:"
is a legal expression, but(: "this is another string (:" :)
results in a syntax error. Literal content can result in an unbalanced nesting of comments.