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 ...
Get XQuery now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.