Chapter 9.  XmlDocument

#include <DbXml.hpp>

class DbXml::XmlDocument {
public:
	XmlDocument();
	XmlDocument(const XmlDocument &);
	~XmlDocument();
	XmlDocument &operator = (const XmlDocument &)
	...
};

An XmlDocument is the unit of storage within an XmlContainer . A document consists of content, a name, and a set of metadata attributes.

The document content is a byte stream. It must be well formed XML, but need not be valid.

The document name is a unique identifier for the document. The name is specified when the document is first placed in the container. It can either be explicitly specified by the user, or it can be auto-generated by Berkeley DB XML. See XmlContainer::putDocument for details.

The user can retrieve the document by name using XmlContainer::getDocument. In addition, the document name can be referenced in an XQuery expression using the doc() navigation function. For example, suppose your document's name is 'doc1.xml' and the container that it exists in is 'container1.bdbxml'. In this case, you can explicitly request the document by it's name using:

doc('dbxml:/container1.bdbxml/doc1.xml')

The metadata attributes provide a means of associating information with a document, without having to store it within the document itself. Example metadata attributes might be: document owner, creation time, receipt time, originating source, final destination, and next processing phase. They are analogous to the attributes of a file in a file system. Each metadata attribute consists of a name-value pair. The document's name is an implicit metadata attribute.

You can access the metadata for a given document by using either XmlDocument::getMetaData or by iterating over the document's metadata. Use XmlDocument::getMetaDataIterator to retrieve an XmlMetaDataIterator object.

You can instantiate an empty XmlDocument object using XmlManager::createDocument. The 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 not thread-safe, and can only be safely used by one thread at a time in an application.

XmlDocument Methods