# XQuery changes

The default collation is now defined and used systematically. If no default collation is specified in the Query Prolog, the collation used for string comparisons and for sorting is the collation `http://saxon.sf.net/collation?lang={lang};strength=tertiary` where the value of `lang` is taken from the Java locale.

Pragmas and must-understand extensions are now recognized. With the exception noted below, pragmas are ignored and must-understand extensions are rejected.

A Saxon-specific pragma has been implemented allowing a default value to be specified for a query parameter (external variable). The syntax is illustrated below:

    declare namespace saxon="http://saxon.sf.net/";
    declare variable $x external (:: pragma saxon:default "20" ::);

The default value must be either a numeric literal or a string literal.

Rules concerning the order of declarations in the Query Prolog are now enforced. These rules have been agreed by the Query Working Group, but are not in the current (November 2003) working draft. The rules require "setter" declarations to precede "non-setter" declarations: the "setters" are the declarations of base-uri, xmlspace, validation mode, default namespaces, and default collation.

A new `run()` method has been added to the `XQueryExpression` object. This takes a JAXP `javax.xml.transform.Result` object as an argument, and runs the query sending results to this `Result` object. This method of running a query is likely to be more efficient than the `iterate()` method, because it avoids building the result tree in memory: nodes are serialized as soon as they are created. This method is now the default way in which query results are output when the processor is run from the command line. The results differ from earlier releases in that, for example, freestanding attribute nodes cannot be output in this form.

In the XQuery API, the version of method `QueryResult.wrap` that takes a `NamePool` as an argument is withdrawn; a `Configuration` must now be supplied. The `QueryResult.serialize` method takes a fourth parameter, the `Configuration`.

Next