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.
| 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:
The following example default element/type namespace declaration sets the URI for element names in the query that do not have prefixes:declare namespace ns1 = "http://mycompany.com";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.