### Berkeley DB Reference Guide: Berkeley DB XML |

### Documents

A Berkeley DB XML document consists of content, a name, an ID, and a set of metadata attributes. The document content is a byte stream, which must be well formed XML, but need not be valid.

The document name is a user-provided identifier for the document. The user can retrieve the document by name through the container query interface. The document name can be referenced in an XPath expression as "dbxml:name". For example, the XPath expression:

>     /*[@dbxml:name= 'abc123']

would retrieve the document with the name "abc123".

The Berkeley DB XML system assigns each document a unique ID when it is inserted into a container. The document ID uniquely identifies the document within a container, and can be used to retrieve the document from its container.

The metadata attributes provide a means of associating information with a document, without having to store the information 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.

There are three parts to the name of a metadata attribute; a namespace URI, a namespace prefix, and a local name. The namespace URI and prefix are optional, but should be used to avoid naming collisions. The system reflects each metadata attribute into the document by adding a namespace declaration attribute and metadata attribute to the document root element. The following code example demonstrates how to associate a metadata attribute with a document:

>     XmlDocument document;
>     document.setContent("<x/>");
>     document.setMetaData("http://acme.com/", "acme", "received", "1-Jan-2002");

The system reflects the metadata attribute into the document as follows:

>     <x xmlns:acme= 'http://acme.com/' acme:received= '1-Jan-2002'/>

The metadata attribute can be queried using the XPath expression:

>     /*[@acme:received= '1-Jan-2002']

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.