Dynamic context and focus
The dynamic context of an expression is the information that is available at the time that the expression is evaluated. The focus, which consists of the context item, context position, and context size, is an important part of the dynamic context.
The focus changes as Db2 XQuery processes each
item in a sequence. The focus consists of the following information:
- Context item
- The atomic value or node that is currently being processed. The context item can be retrieved by
the context item expression, which consists of a single dot (
.
). - Context position
- The position of the context item in the sequence that is currently being processed. The context item can be retrieved by the fn:position() function.
- Context size
- The number of items in the sequence that is currently being processed. The context size can be retrieved by the fn:last() function.