Chapter 18.  XmlManager

#include <DbXml.hpp>

XmlManager::XmlManager(DB_ENV *dbenv, u_int32_t flags = 0)
XmlManager::XmlManager(u_int32_t flags)
XmlManager::XmlManager()
XmlManager::XmlManager(const XmlManager &o)
XmlManager &operator = (const XmlManager &o)
XmlManager::~XmlManager()

Provides a high-level object used to manage various aspects of Berkeley DB XML usage. You use XmlManager to perform activities such as container management (including creation and open), preparing XQuery queries, executing one-off queries, creating transaction objects, creating update and query context objects, and creating input streams.

A copy constructor and assignment operator are provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.

This object is free threaded, and can be safely shared among threads in an application.

There are several forms of the constructor available for this class; one that accepts an environment handle, one that uses a private internal environment, and a default constructor.

Using the constructor with an environment handle

#include <DbXml.hpp>

XmlManager::XmlManager(DB_ENV *dbenv, u_int32_t flags = 0) 

XmlManager constructor that uses the provided DB_ENV for the underlying environment. The Berkeley DB subsystems initiated by this environment (for example, transactions, logging, the memory pool), are the subsystems that are available to Berkeley DB XML when operations are performed using this manager object.

Parameters are:

dbenv

The DB_ENV to use for the underlying database environment. The environment provided here must be opened.

flags

Must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

  • DBXML_ALLOW_EXTERNAL_ACCESS

    If set, this flag allows XQuery queries to access data sources external to the container, such as files on disk or http URIs. By default, such access is not allowed.

  • DBXML_ALLOW_AUTO_OPEN

    If set, XQuery queries that reference unopened containers will automatically open those containers, and close them when references resulting from the query are released. By default, a query will fail if it refers to containers that are not open.

  • DBXML_ADOPT_DBENV

    If set, the XmlManager object will close and delete the underlying DB_ENV handle at the end of the XmlManager's life.

Using the constructor with an internal environment

#include <DbXml.hpp>

XmlManager::XmlManager(u_int32_t flags = 0) 

XmlManager constructor that uses a private internal database environment. This environment is opened with DB_PRIVATE|DB_CREATE|DB_INIT_MPOOL. These flags allow the underlying environment to be created if it does not already exist. In addition, the memory pool (in-memory cache) is initialized and available. Finally, the environment is private, which means that no external processes can join the environment, but the XmlManager object can be shared between threads within the opening process.

Note that for this form of the constructor, the environment home is located in either the current working directory, or in the directory identified by the DB_HOME environment variable.

Parameters are:

flags

Must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

  • DBXML_ALLOW_EXTERNAL_ACCESS

    If set, this flag allows XQuery queries to access data sources external to the container, such as files on disk or http URIs. By default, such access is not allowed.

  • DBXML_ALLOW_AUTO_OPEN

    If set, XQuery queries that reference unopened containers will automatically open those containers, and close them when references resulting from the query are released. By default, a query will fail if it refers to containers that are not open.

Default constructor

#include <DbXml.hpp>

XmlManager::XmlManager()

A default XmlManager constructor. This constructor provides the same behavior as passing a flags parameter of 0 to the constructor that takes a single flags parameter. This constructor is provided for convenience.

Errors

The XmlManager constructor may fail and throw XmlException , encapsulating one of the following non-zero errors:

INTERNAL_ERROR

You used a form of the constructor that does not take an external DB_ENV handle, and an error occured opening the default database environment.

INVALID_VALUE

You provided an invalid value to the flags parameter.

XmlManager Methods