Database Reference
In-Depth Information
right XML document(s) and/or design your collection structure carefully to constrain
this.
$modifications contains your XUpdate document.
The function returns the number of updates applied.
Controlling the Database from Code
Learning how to control the database from XQuery code is important because when
writing an application, sooner or later you'll want to create or delete documents and
collections, change their properties, interrogate them, and so on. It's all part of the
game.
Most functions for controlling the database are in eXist's xmldb extension module. To
find the exact details of these functions, refer to the online eXist module documenta‐
tion in the XQuery Function Documentation app in the dashboard. In this section,
we will provide you with an overview.
This subject is somewhat dependent on that of security. For instance, if you try to
create a document but the parent collection doesn't allow the current user to do so,
you have a problem. Also, after you've created something you'll probably want to set
its security properties (owner, group, permissions), right? Security is a big subject and
is handled in depth in Chapter 8 . This section provides you only with the basic infor‐
mation of how to work with the various security-related settings, not their meaning.
In general, eXist's security system closely mimics that of UNIX systems.
Specifying Collections and Resources for the xmldb Extension Module
The xmldb extension module is somewhat fickle in how it handles addressing collec‐
tions and resources:
• A collection must always be passed as a URL-escaped URI (of type xs:string ),
as specified in “Use URIs” on page 91 . For instance:
xmldb:get-child-resources ( "/db/new%20collection" )
• A resource name can be passed as a URL-escaped URI, but surprisingly also as a
normal, nonescaped string. Therefore, the following function calls are equivalent:
xmldb:size ( "/db/new%20collection" , "new document.xml" )
xmldb:size ( "/db/new%20collection" , "new%20document.xml" )
Search WWH ::




Custom Search