Setting the Query Context

Every query is analyzed and evaluated within a context that is defined by the implementation. This context includes settings like implicit time zone, context node, and default collation. In some cases, the settings of the context can be overridden by prolog declarations in the query, but sometimes they cannot. It is useful to know what defaults and choices your implementation supports for these settings.

Your implementation may do any of the following to augment the built-in functions and features of the XQuery language:

  • Add built-in functions

  • Add predeclared namespaces (including a default element and function namespace)

  • Add built-in schemas, whose type names can be used in queries and whose element and attribute declarations can be used in validation

  • Add built-in global variables and their values

  • Specify a list of supported collations

In addition, your implementation may set default values for any of the prolog "setters," namely:

  • Boundary-space policy

  • Ordering mode

  • Empty-order specification

  • Copy-namespaces mode

  • Construction mode

  • Default collation

  • Base-URI of the static context

The implementation may or may not allow you the option of overriding these settings outside the scope of the query. For example, you may be allowed to enter them into a dialog box in a user interface, specify them at a command-line prompt, or set them programmatically. However, any settings specified in the query prolog take priority.

Get XQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.