DB2 10.5 for Linux, UNIX, and Windows

Statically known namespaces

Namespace prefixes are bound to URIs by namespace declarations. The set of these namespace bindings that control the interpretation of QNames in a query expression is called the statically known namespaces. Statically known namespaces are properties of a query expression and are independent of the data that is processed by the expression.

Some namespace prefixes are predeclared; others can be added through declarations in either the query prolog or an element constructor. DB2® XQuery includes the predeclared namespace prefixes that are described in the following table.

Table 1. Predeclared namespaces in DB2 XQuery
Prefix URI Description
xml http://www.w3.org/XML/1998/namespace XML reserved namespace
xs http://www.w3.org/2001/XMLSchema XML Schema namespace
xsi http://www.w3.org/2001/XMLSchema-instance XML Schema instance namespace
fn http://www.w3.org/2005/xpath-functions Default function namespace
xdt http://www.w3.org/2005/xpath-datatypes XQuery type namespace
db2-fn http://www.ibm.com/xmlns/prod/db2/functions DB2 function namespace
In addition to the predeclared namespaces, a set of statically known namespaces can be provided in the following ways:
  • Declared in the query prolog, using either a namespace declaration or a default namespace declaration. The following example namespace declaration associates the namespace prefix ns1 with the URI http://mycompany.com:
    declare namespace ns1 = "http://mycompany.com";
    The following example default element/type namespace declaration sets the URI for element names in the query that do not have prefixes:
    declare default element namespace "http://posample.org";
  • Declared by a namespace declaration attribute in an element constructor. The following example is an element constructor that contains a namespace declaration attribute that binds the prefix ns2 to the URI http://mycompany.com within the scope of the constructed element:
    <ns2:price xmlns:ns2="http://mycompany.com">14.99</ns2:price>
  • Provided by SQL/XML. SQL/XML can provide the following set of namespaces:
    • SQL/XML predeclared namespaces.
    • Namespaces that are declared within SQL/XML constructors and other SQL/XML expressions.
    Namespaces that are provided by SQL/XML can be overridden by namespace declarations in the prolog, or subsequent namespace declaration attributes in element constructors. Namespaces that are declared in the prolog can be overridden by namespace declaration attributes in element constructors.