An embedded XML Database: Oracle Berkeley DB XML

There is more to life than RDBMS

Using the Command Shell

The dbxml shell may be started with the dbxml command:

C:/>dbxml

The following prompt gets displayed:

dbxml>

Berkeley DB XML commands may be specified at the dbxml command prompt. Let’s first create a container to store XML documents using the createContainer command:

dbxml>createContainer catalog.dbxml

A node storage container with nodes indexed gets created and opened (see Figure 3):

Creating a Container.

The BDB XML database is just a .dbxml file created in the directory in which the dbxml command was issued.

Adding XML Documents

Next, we’ll add XML documents to the container, using the putDocument command. For example, add an XML document that represents a catalog entry:

dbxml>putDocument catalog1 '<catalog title="Oracle Magazine" publisher="Oracle Publishing"> …
</catalog>' s

Single quotes are used for any command parameters that span multiple lines or contain spaces. The character ‘s’ used to terminate the command indicates that the XML document is added using a string.

Adding an XML Document.

Similarly add another catalog ‘catalog2’. The XML documents added may be retrieved with the getDocuments command:

dbxml>getDocuments

The documents retrieved may be output to stdout with the print command:

dbxml>print

Outputting Added Document.

Querying XML Documents with Xquery

XQuery queries retrieve subsets of data similarly to the use of SELECT statement in SQL. Each query has two parts; the first part identifies the set of documents to be queried using an XQuery navigation function such as collection() or doc(). The collection() function is used to navigate to a container. The doc() function may be used to navigate to a specified XML document in a container. As an example of a query select all the article titles in the catalog.dbxml container using the query command:

dbxml>query 'collection("catalog.dbxml")/catalog/journal/article/title/text()'

To output the results of the query use the print command:

dbxml>print
Using Bind Variables
From Application Express to XE

Sponsored: From CDO to CEO

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER




Biting the hand that feeds IT © 1998–2019