Namespace Declarations in Queries
There are three ways that namespaces are mapped to prefixes in XQuery queries:
Some namespaces are predeclared; no explicit namespace declaration is necessary to associate a prefix with the namespace.
Namespace declarations can appear in the query prolog.
Namespace declarations can appear in direct XML constructors.
The examples in this section use the input document cat_ns.xml shown in Example 10-4.
Predeclared Namespaces
For convenience, five commonly used namespace declarations are built into the XQuery recommendation. They are listed in Table 10-1. The five prefixes can be used anywhere in a query even if they are not explicitly declared by a namespace declaration. These prefixes are also used throughout this book to represent the appropriate namespaces.
Table 10-1. Predeclared namespaces
|
Prefix |
Namespace |
Uses |
|---|---|---|
|
xml |
XML attributes such as | |
|
xs |
XML Schema built-in types and their constructors | |
|
xsi |
XML Schema instance attributes such as | |
|
fn |
XPath Functions Namespace: the default namespace of all built-in functions | |
|
local |
Functions declared in a main module that are not in a specific namespace |
In addition, your XQuery implementation may predeclare other namespaces for use within your ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access