Configuring the BerkeleyDBXML.xml File

You need to configure the BerkeleyDBXML.xml file in order to be able to save XML documents back to a Berkeley DB XML container. Until you configure the BerkeleyDBXML.xml file as described in this section, any files you read from Berkeley DB XML are marked read-only and cannot be written back to Berkeley DB XML.

The Berkeley Database Environment

The Berkeley database has the concept of a database environment. The database environment is typically a directory that contains the log and lock files that provide support for transaction processing. This directory may also contain databases - files that contain user data. The containers in which Berkeley DB XML stores XML documents are examples of Berkeley databases and typically, though not always, have a .dbxml extension.

To be able to determine what database environments exist in Berkeley DB XML, and which ones are associated with which containers, you need to

  • Modify the BerkeleyDBXML.xml configuration file
  • Validate your changes using the BerkeleyDBXML.xsd XML Schema

These files are installed in the \bin\lib\sleepycat directory where you installed Stylus Studio ( c:\Program Files\Stylus Studio 2007 XML Professional Suite\bin\lib\sleepycat, for example).

The BerkeleyDBXML.xml Configuration File

The BerkeleyDBXML.xml configuration file contains elements that allow you to specify Berkeley DB XML database environments and directories:

  • <dbenv> - The pathname of a database environment.
  • <dbdir> - A directory within that database environment that stores the containers you wish to access.

A finished BerkeleyDBXML.xml configuration file might look like this:

<dbxml>
               
   <dbenv path="c:\dbenv1">
               
      <dbdir path="d:\datadir1"/>
               
      <dbdir path="e:\datadir2"/>
               
   </dbenv>
               
   <dbenv path="c:\testenv">
               
      <dbdir path="c:\testdata"/>
               
   </dbenv>
               
   <dbenv path="c:\testenv2"/>
               
</dbxml>
               

            

Omitting <dbdir> and <dbenv> elements

In some cases, it is not necessary do have any <dbdir> elements, as is illustrated by the <dbenv path="c:\testenv2"/> element in the example BerkeleyDBXML.xml configuration file. You can omit the <dbdir> element

  • If it has the same path as its <dbenv> parent.
  • If you have a DB_CONFIG file in a database environment - Stylus Studio reads the set_data_dir entries in that file. (See the Berkeley DB XML API documentation for more information on the DB_CONFIG file.)

If you use the DB_HOME environment variable to locate your database environment and all its data directories are listed in the DB_CONFIG file for that database environment, you can omit that database environment from the BerkeleyDBXML.xml configuration file. Indeed, if that is your only database environment, you do not need the BerkeleyDBXML.xml configuration file at all.

Specifying <dbdir> pathnames

Pathnames you specify for <dbdir> elements can be absolute or relative. Relative pathnames are relative to the enclosing <dbenv> pathname, not to your current working directory.

The validate attribute

In Berkeley DB XML Version 2.0.7 and 2.0.9, the <dbxml>, <dbenv>, and <dbdir> elements have a validate attribute that allows Sleepycat to validate XML documents before saving them to the Berkeley DB XML file system. See Validating Documents for more information on this topic.

How to Configure BerkeleyDBXML.xml

To configure BerkeleyDBXML.xml:
1. Open the BerkeleyDBXML.xml configuration file in Stylus Studio.
2. Specify the <dbenv> and <dbdir> elements as described in The BerkeleyDBXML.xml Configuration File.
3. Click Validate Document .
4. If the BerkeleyDBXML.xml configuration file is valid, save your changes.

You are ready to use Berkeley DB XML with Stylus Studio.

Open the Output Window

The first time you perform an operation on the Berkeley DB XML, Stylus Studio tries to process the BerkeleyDBML.xml file. As the file is processed, messages are written to the Stylus Studio Output window. These messages identify which database environments and directories are being processed. This can be a useful way to verify which directories Stylus Studio is associating with which database environment and identify when you might need to make a change in the BerkeleyDBXML.xml file.

 
Free Stylus Studio XML Training:
W3C Member