Context steps and function expression steps

The context step and function expression step are part of the XML index pattern specified when creating functional indexes over XML data. The context step defines the XML index pattern of the set of elements or attribute nodes to be indexed. The function expression step specifies the function that defines the key values to be stored in the index.

In general, when you create functional indexes over XML data, for example by using the fn:exists and fn:upper-case functions, the XML pattern expression that you specify in the GENERATE KEYS USING XMLPATTERN clause has two parts.

The first part is called the context step. The context step specifies the XML path of the element nodes or attribute nodes for which index entries will be created. The syntax of the context step follows the same syntax as the index pattern expression for XML indexes in general, but has certain restrictions when used together with specific functions, such as fn:upper-case and fn:exists. See information about using the CREATE INDEX statement for details.

The second part is called the function expression step. The function expression step specifies the function, such as fn:exists or fn:upper-case, and its parameters. The function expression step produces the actual key value to be stored in the index for each node specified by the context step.

For example, for the index XML pattern /a/b/fn:upper-case(.):
  • The context step is /a/b
  • The function expression step is fn:upper-case(.)
As another example, for the index XML pattern /a/b/fn:exists(c):
  • The context step is /a/b
  • The function expression step fn:exists(c)