1.15.5 XQuery declaration

Organization of this subsection
(1) Function
(2) Format
(3) Operands

(1) Function

Declares the XML namespaces for the qualified names used in an XQuery query.

(2) Format

XQuery-declaration ::= [{XML-namespace-declaration|default-XML-namespace-declaration};]...

XML-namespace-declaration ::= declare namespace prefix = XML-namespace-URI
default-XML-namespace-declaration ::= declare default {element|function}
                namespace XML-namespace-URI

(3) Operands

If the body of an XQuery query contains prefixed qualified names, declares the XML namespace corresponding to the prefix for those qualified names.

The same prefix cannot be declared for multiple XML namespaces.

prefix
Specifies the prefix used to qualify names in the body of an XQuery query.
XML-namespace-URI
Specifies the URI of the XML namespace corresponding to the prefix in the format of an XQuery character string literal.
A character string of length 0 can be specified in order to unmap the XML namespace from the XML namespace prefix defined in Table 1-50 Prefixes defined in HiRDB.

Declares the default XML namespace to be used in the body of the Xquery query. The XML namespace for any qualified name in the XQuery query that does not have a prefix will be searched for in the XML namespace declared here.

In XQuery, both a default XML namespace declaration for specifying elements and a default XML namespace declaration for specifying functions can be declared, but only one of each.

If no declaration is made, the XML namespace URI for the default XML namespace to be used for both XML element names and XQuery data type names is assumed to be http://www.w3.org/XML/1998/namespaces, and the XML namespace URI for the default XML namespace to be used for XQuery functions is assumed to be http://www.w3.org/2006/xpath-functions.

element
Specified in order to declare the default XML namespace for XML element names and XQuery data type names.
function
Specified in order to declare the default XML namespace for XQuery function names.
XML-namespace-URI
Specifies the XML namespace URI for unprefixed qualified names in the format of an XQuery character string literal.
If a character string of length 0 is specified, any unprefixed qualified name will not belong to any XML namespace.