Chapter 4.  Berkeley DB XML XQuery Extension Functions

Table of Contents

fn:collection()
Parameters
URI Resolution in Berkeley DB XML
dbxml:contains()
fn:doc()
dbxml:lookup*()
dbxml:metadata()
dbxml:node*()

Berkeley DB XML supports the XQuery Specification from the W3C. The specification includes a large number of functions, and also supports the writing of extension functions. Berkeley DB XML includes a number of extension functions that are in the Berkeley DB XML namespace, http://www.sleepycat.com/2002/dbxml, which is assumed to be bound to the prefix "dbxml" in this documentation.

The functions signatures follow that of the specification. In addition to documenting the Berkeley DB XML XQuery extension functions, the treatment of the arguments to fn:collection() and fn:doc() in the context of Berkeley DB XML.

This documentation covers only those areas where Berkeley DB XML extends the specification or has implementation-defined behavior. See the XQuery Specification or other resources as XQuery references. The following functions are interpreted and implemented in Berkeley DB XML:

fn:collection()

fn:collection($arg as xs:string?) as node()*

Returns a sequence of nodes obtained by interpreting $arg as an xs:anyURI. If $arg is not specified, the default collection is used if it is set. See the specification for details.

Parameters

$arg

A URI representing the collection.

URI Resolution in Berkeley DB XML

A URI representing an Berkeley DB XML container is of the form, "dbxml:/container_alias," where "container_alias" is an absolute or relative path to the container, or an alias added using XmlContainer::addAlias(). If the URI is either of the form "dbxml:////absolute_path_to_container" or "dbxml:/C:/absolute_windows_path_to_container" (Windows) then the path is considered absolute; otherwise, it is relative to the Berkeley DB environment's data directory. In general, it's simplest to use an explicit alias. It is also important to note that the Berkeley DB XML query optimizer uses the argument to fn:collection() to determine which indices may be appropriate for a given query.

By default, the base URI in an XmlQueryContext is "dbxml:/" which allows use of "collection('relative_path_to_container')" without any additional code. It is possible to use XmlQueryContext::setBaseURI() to change the default base URI. Note also that the Windows pathname separator, '\', is not a valid separator in a URI; the forward slash ('/') must be used, even on Windows.

Some applications may choose to implement their own name resolution scheme for the argument to fn:collection(). This is supported by allowing applications to control the resolution process using an application-provided instance of the XmlResolver class, and using a URI that looks like (for example) "myscheme:/my_name_for_container." Collections located in this manner cannot currently be optimized by indices.