BDBXML and default namespaces

If you’re looking to do some simple XQuery work, Berkeley DB XML (BDBXML) seems to be a good answer.

The XML that I was loading into the DB has a default namespace. For example:

<?xml version="1.0" encoding="UTF-8"?>
<item xmlns="http://example.org/item"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/item item.xsd">
<size>...</size>
...
<item>

Unfortunately BDBXML does not allow one to declare the default namespace:

xmlQueryContext.setNamespace("", "http://example.org/item");

You must bind a prefix to the namespace and use that in any XQuery / XPath:


xmlQueryContext.setNamespace("i", "http://example.org/item");
[query]
/i:item/i:size
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s