Database Reference
In-Depth Information
Accessing external databases using extended XMLDB URIs
The XMLDB extension function collection parameters all accept an extended syntax
for the XMLDB URIs, as described in
“XMLDB URIs” on page 92
:
xmldb:exist://username:password@server:port/exist/xmlrpc/db/...
You can use this to access remote servers and update their databases directly.
Getting Information
There are many functions in eXist's
xmldb
extension module that can provide you
with information about the database's content. Here is an overview of the most
important ones:
xmldb:last-modified
,
xmldb:size
,
xmldb:get-mime-type
Retrieve the basic properties of a resource.
Most
xmldb
functions take two parameters—a collection and a
document URI—but
xmldb:get-mime-type
is an exception (for
unknown reasons). It takes the full URI to the document as its
input.
Additionally, you should note that
xmldb:size
will not give you
the exact size of an XML resource, but an estimate based on the
number of database pages the document occupies.
xmldb:get-owner
,
xmldb:get-group
,
xmldb:get-permissions
Retrieve the security settings for a collection or resource.
Permissions are returned as integer values; the function
xmldb:permissions-to-
string
turns these into something more readable. It is strongly recommended
instead to use the newer
sm:get-permissions
function from the Security Mod‐
ule instead.
xmldb:get-child-collections
,
xmldb:get-child-resources
Provide you with sequences of the child collections or resources of a given parent
collection. You can use these functions to traverse and inspect the database's col‐
lection/resource structure.
Example 5-2
is a little XQuery program that displays
the database's content. It uses a recursive function to traverse the collection tree,
which is a pattern you'll see quite often in XQuery code.
Example 5-2. Traversing and displaying the database structure
xquery
version
"1.0"
encoding
"UTF-8"
;
declare
option
exist:serialize
"method=html media-type=text/html indent=no"
;
Search WWH ::
Custom Search