Option Declarations and Extension Expressions
Two methods are available for specifying the values of implementation-specific settings in the query itself: option declarations and extension expressions. This section describes how these settings are defined and used. The documentation for your XQuery implementation should provide information on what specific options and extensions it supports.
The Option Declaration
An option declaration can be used to specify an implementation-defined setting in the query prolog. This is useful for settings that affect the entire query, or other settings in the prolog. The syntax of an option declaration is shown in Figure 23-1.
Figure 23-1. Syntax of an option declaration
The Saxon implementation allows for several different types of options. Example 23-1 shows two of them.
Example 23-1. Option declarations
declare namespace saxon="http://saxon.sf.net/"; declare option saxon:default "25"; declare variable $maxRowsToReturn external; declare option saxon:output "method=xhtml";
The first option declaration, for saxon:default
, is used to specify a default value for the global variable whose declaration follows it. If no value is supplied for $maxRowsToReturn
outside the scope of the query, the value 25 is used. The second option declaration, for saxon:output
, is used to specify values for serialization parameters, in this case, the output method when serializing ...
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.