XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/xmldb

java:org.exist.xquery.functions.xmldb.XMLDBModule

A module for database manipulation functions.

xmldb:add-user-to-group

xmldb:add-user-to-group($user as xs:string, $group as xs:string) as xs:boolean

Add a user to a group. $user is the username. $group is the group nameThe XQuery owner must have appropriate privileges to do this, e.g. having DBA role.

Parameters:
$user The user name
$group The group name
Returns:
xs:boolean : true() or false() indicating the outcome of the operation
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:add-group-member' instead! This function could be removed in the next major release version.

xmldb:authenticate

xmldb:authenticate($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?) as xs:boolean

Check if the user, $user-id, can authenticate against the database collection $collection-uri. The function simply tries to read the collection $collection-uri, using the credentials $user-id and $password. Collection URIs can be specified either as a simple collection path or an XMLDB URI. It returns true if the authentication succeeds, false otherwise.

Parameters:
$collection-uri The collection URI
$user-id? The user-id
$password? The password
Returns:
xs:boolean : true() on successful authentication, false() otherwise

xmldb:change-user

xmldb:change-user($user-id as xs:string, $password as xs:string?, $groups as xs:string*) as item()

Change properties of an existing database user. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships, The username, $user-id, is mandatory. Non-empty values for the other parameters are optional, where if empty the existing value is used.

Parameters:
$user-id The user-id
$password? The password
$groups* The groups the user is member of
Returns:
item()
Deprecated:
Use either sm:passwd for changing a password or sm:add-group-member to add a user to a group or sm:remove-group-member to remove a user from a group. This function could be removed in the next major release version.

xmldb:change-user

xmldb:change-user($user-id as xs:string, $password as xs:string?, $groups as xs:string*, $home-collection as xs:string?) as item()

Change properties of an existing database user. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships, $home-collection is the home collection. The username, $user-id, is mandatory. Non-empty values for the other parameters are optional, where if empty the existing value is used.

Parameters:
$user-id The user-id
$password? The password
$groups* The groups the user is member of
$home-collection? The user's home collection
Returns:
item()
Deprecated:
$home-collection has no effect since 2.0. Use either sm:passwd for changing a password or sm:add-group-member to add a user to a group or sm:remove-group-member to remove a user from a group. This function could be removed in the next major release version.

xmldb:chmod-collection

xmldb:chmod-collection($collection as xs:string, $mode as xs:integer) as item()

Sets the mode of collection $collection. $mode is the mode as xs:integer. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience.

Parameters:
$collection The collection path
$mode The mode as xs:integer
Returns:
item()
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:chmod' instead! This function could be removed in the next major release version.

xmldb:chmod-resource

xmldb:chmod-resource($collection as xs:string, $resource as xs:string, $mode as xs:integer) as item()

Sets the mode of the resource $resource in collection $collection, $mode is the mode as xs:integer. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience.

Parameters:
$collection The collection
$resource The resource
$mode The mode as xs:integer
Returns:
item()
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:chmod' instead! This function could be removed in the next major release version.

xmldb:clear-lock

xmldb:clear-lock($collection-uri as xs:string, $resource as xs:string) as xs:string?

Removes the user lock on the resource $resource in the collection $collection-uri. If no lock is in place, the empty sequence is returned. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:string? : the user id of the previous lock owner, otherwise if not locked the empty sequence

xmldb:collection-available

xmldb:collection-available($collection-uri as xs:string) as xs:boolean

Returns true() if the collection $collection-uri exists and is available, otherwise false(). Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:boolean : true() if the collection exists and is available, false() otherwise

xmldb:copy

xmldb:copy($source-collection-uri as xs:string, $target-collection-uri as xs:string) as item()

Copy the collection $source-collection-uri to the collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$source-collection-uri The source collection URI
$target-collection-uri The target collection URI
Returns:
item()

xmldb:copy

xmldb:copy($source-collection-uri as xs:string, $target-collection-uri as xs:string, $resource as xs:string) as item()

Copy the resource $resource in $source-collection-uri to collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$source-collection-uri The source collection URI
$target-collection-uri the target collection URI
$resource the resource to copy
Returns:
item()

xmldb:create-collection

xmldb:create-collection($target-collection-uri as xs:string, $new-collection as xs:string) as xs:string?

Create a new collection with name $new-collection as a child of $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.Returns the path to the new collection if successfully created, otherwise the empty sequence.

Parameters:
$target-collection-uri The target collection URI
$new-collection The name of the new collection to create
Returns:
xs:string? : the path to the new collection if successfully created, otherwise the empty sequence

xmldb:create-group

xmldb:create-group($group as xs:string) as xs:boolean

Create a new user group. $group is the group name. The current user will be the groups manager.

Parameters:
$group The group name
Returns:
xs:boolean : true() or false() indicating the outcome of the operation
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:create-group' instead! This function could be removed in the next major release version.

xmldb:create-group

xmldb:create-group($group as xs:string, $group-manager-username as xs:string+) as xs:boolean

Create a new user group, with an initial member. $group is the group name, $group-manager-username are the groups managers in addition to the current user.

Parameters:
$group The group name
$group-manager-username+ The name of the user(s) who will be the groups manager
Returns:
xs:boolean : true() or false() indicating the outcome of the operation
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:create-group' instead! This function could be removed in the next major release version.

xmldb:create-user

xmldb:create-user($user-id as xs:string, $password as xs:string, $groups as xs:string+) as item()

Create a new user, $user-id, in the database. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships. The first group in the sequence is the primary group.Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$user-id The user-id
$password The password
$groups+ The group memberships
Returns:
item()
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:create-account' instead! This function could be removed in the next major release version.

xmldb:create-user

xmldb:create-user($user-id as xs:string, $password as xs:string, $groups as xs:string+, $home-collection-uri as xs:string?) as item()

Create a new user, $user-id, in the database. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role. $user-id is the username, $password is the password, $groups is the sequence of group memberships. The first group in the sequence is the primary group.$home-collection-uri is the home collection URI.Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$user-id The user-id
$password The password
$groups+ The group memberships
$home-collection-uri? The home collection URI
Returns:
item()
Deprecated:
$home-collection-uri has no effect since 2.0. You should use the sm:create-account function from the SecurityManager module instead. This function could be removed in the next major release version.

xmldb:created

xmldb:created($collection-uri as xs:string) as xs:dateTime

Returns the creation date of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:dateTime : the creation date

xmldb:created

xmldb:created($collection-uri as xs:string, $resource as xs:string) as xs:dateTime

Returns the creation date of the resource $resource in $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:dateTime : the creation date

xmldb:decode

xmldb:decode($string as xs:string) as xs:string

Decodes the string $string such that any percent encoded octets will be translated to their decoded UTF-8 representation.

Parameters:
$string The input string
Returns:
xs:string : the decoded string

xmldb:decode-uri

xmldb:decode-uri($uri as xs:anyURI) as xs:string

Decodes the URI $uri such that any percent encoded octets will be translated to their decoded UTF-8 representation.

Parameters:
$uri The URI
Returns:
xs:string : the decoded $uri as xs:string

xmldb:defragment

xmldb:defragment($nodes as node()+) as item()

Start a defragmentation run on each document which has a node in $nodes. Fragmentation may occur if nodes are inserted into a document using XQuery update extensions. Please note that defragmenting a document changes its internal structure, so any references to this document will become invalid, in particular, variables pointing to some nodes in the document.

Parameters:
$nodes+ The sequence of nodes from the documents to defragment
Returns:
item()

xmldb:defragment

xmldb:defragment($nodes as node()+, $integer as xs:integer) as item()

Start a defragmentation run on each document which has a node in $nodes. Fragmentation may occur if nodes are inserted into a document using XQuery update extensions. The second argument specifies the minimum number of fragmented pages which should be in a document before it is considered for defragmentation. Please note that defragmenting a document changes its internal structure, so any references to this document will become invalid, in particular, variables pointing to some nodes in the document.

Parameters:
$nodes+ The sequence of nodes from the documents to defragment
$integer The minimum number of fragmented pages required before defragmenting
Returns:
item()

xmldb:delete-user

xmldb:delete-user($user-id as xs:string) as item()

Deletes an existing user, $user-id, in the database. This does not delete the user's home collection. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role, and not being the owner of the currently running XQuery. You cannot delete the owner of the currently running XQuery.

Parameters:
$user-id The user-id to delete
Returns:
item()
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:remove-account' instead! This function could be removed in the next major release version.

xmldb:document

xmldb:document($document-uris as xs:string+) as node()*

Returns the documents $document-uris in the input sequence. Collection URIs can be specified either as a simple collection path or an XMLDB URI.If the input sequence is empty, the function will load all documents in the database.

Parameters:
$document-uris+ The document URIs
Returns:
node()* : the documents
Deprecated:
See the standard fn:doc() function This function could be removed in the next major release version.

xmldb:document-has-lock

xmldb:document-has-lock($collection-uri as xs:string, $resource as xs:string) as xs:string?

Returns the user-id of the user that holds a write lock on the resource $resource in the collection $collection-uri. If no lock is in place, the empty sequence is returned. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:string? : the user id of the lock owner, otherwise if not locked the empty sequence

xmldb:encode

xmldb:encode($string as xs:string) as xs:string

Encodes the string $string such that it will be a valid collection or resource path. Provides similar functionality to java's URLEncoder.encode() function, with some enhancements.

Parameters:
$string The input string
Returns:
xs:string : the URL encoded string

xmldb:encode-uri

xmldb:encode-uri($string as xs:string) as xs:anyURI

Encodes the string $string such that it will be a valid collection or resource path. Provides similar functionality to java's URLEncoder.encode() function, with some enhancements. Returns an xs:anyURI object representing a valid XmldbURI

Parameters:
$string The input string
Returns:
xs:anyURI : the XmldbURI encoded from $string

xmldb:exists-user

xmldb:exists-user($user-id as xs:string) as xs:boolean

Returns true if the user $user-id exists.

Parameters:
$user-id The user-id
Returns:
xs:boolean : true() if the user exists, false() otherwise
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:user-exists' instead! This function could be removed in the next major release version.

xmldb:find-last-modified-since

xmldb:find-last-modified-since($node-set as node()*, $since as xs:dateTime) as node()*

Filters the given node set to only include nodes from resources which were modified since the specified date time.

Parameters:
$node-set* A node set
$since Date
Returns:
node()* : the filtered node set.

xmldb:find-last-modified-until

xmldb:find-last-modified-until($node-set as node()*, $until as xs:dateTime) as node()*

Filters the given node set to only include nodes from resources which were modified until the specified date time.

Parameters:
$node-set* A node set
$until Date
Returns:
node()* : the filtered node set.

xmldb:get-child-collections

xmldb:get-child-collections($collection-uri as xs:string) as xs:string*

Returns the names of the child collections in the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:string* : the sequence of child collection names

xmldb:get-child-resources

xmldb:get-child-resources($collection-uri as item()) as xs:string*

Returns the names of the child resources in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:string* : the sequence of resource names

xmldb:get-current-user

xmldb:get-current-user() as xs:string

Returns the user-id of the current user from the xquery context.

Returns:
xs:string : the user-id of the current user
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:id' instead! This function could be removed in the next major release version.

xmldb:get-current-user-attribute

xmldb:get-current-user-attribute($name as xs:string) as xs:string?

Returns the attribute of the current user account.

Parameters:
$name The name of the user attribute
Returns:
xs:string? : the attribute value of the current user
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-account-metadata' instead! This function could be removed in the next major release version.

xmldb:get-current-user-attribute-names

xmldb:get-current-user-attribute-names() as xs:string*

Returns the names of the attributes of the current user.

Returns:
xs:string* : the attribute names of the current user
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-account-metadata-keys' instead! This function could be removed in the next major release version.

xmldb:get-group

xmldb:get-group($collection-uri as xs:string) as xs:string?

Returns the owner group of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:string? : the owner group
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-group

xmldb:get-group($collection-uri as xs:string, $resource as xs:string) as xs:string?

Returns the owner group of the resource $resource in the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:string? : the owner group
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-mime-type

xmldb:get-mime-type($resource-uri as xs:anyURI) as xs:string?

Returns the MIME type if available of the resource $resource-uri, otherwise the empty sequence. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.

Parameters:
$resource-uri The resource URI
Returns:
xs:string? : the mime-type if available, otherwise the empty sequence

xmldb:get-owner

xmldb:get-owner($collection-uri as item()) as xs:string?

Returns the owner user-id of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
xs:string? : the user-id
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-owner

xmldb:get-owner($collection-uri as item(), $resource as xs:string) as xs:string?

Returns the owner user-id of the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:string? : the user-id
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-permissions

xmldb:get-permissions($collection-uri as xs:string) as xs:int?

Returns the permissions assigned to the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection-uri
Returns:
xs:int? : the collection permissions
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-permissions

xmldb:get-permissions($collection-uri as xs:string, $resource as xs:string) as xs:int?

Returns the permissions assigned to the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection-uri
$resource The resource
Returns:
xs:int? : the resource permissions
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-permissions' instead! This function could be removed in the next major release version.

xmldb:get-user-groups

xmldb:get-user-groups($user-id as xs:string) as xs:string+

Returns the sequence of groups the user $user-id is a member of.

Parameters:
$user-id The user-id
Returns:
xs:string+ : the group memberships
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-user-groups' instead! This function could be removed in the next major release version.

xmldb:get-user-home

xmldb:get-user-home($user-id as xs:string) as xs:anyURI?

Returns the user's home collection URI or the empty sequence if no home collection is assigned to the user $user-id.

Parameters:
$user-id The user-id
Returns:
xs:anyURI? : the home collection URI of user $user-id if one is assigned, otherwise the empty sequence
Deprecated:
Users do not have home collections since 2.0. Will return /db. This function could be removed in the next major release version.

xmldb:get-user-primary-group

xmldb:get-user-primary-group($user-id as xs:string) as xs:string

Returns the user's primary group.

Parameters:
$user-id The user-id
Returns:
xs:string : The Primary Group of the User
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-user-primary-group' instead! This function could be removed in the next major release version.

xmldb:get-users

xmldb:get-users($group-name as xs:string) as xs:string*

Returns the list of users in the group

Parameters:
$group-name The group-name
Returns:
xs:string* : The list of users in the group identified by $group-name
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:get-group-members' instead! This function could be removed in the next major release version.

xmldb:group-exists

xmldb:group-exists($group as xs:string) as xs:boolean

Determines whether a group exists. $group is the group name, The current user must have permission to access the group, i.e. be a member of the group or DBA

Parameters:
$group The group name
Returns:
xs:boolean : true() or false() indicating the outcome of the operation
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:group-exists' instead! This function could be removed in the next major release version.

xmldb:is-admin-user

xmldb:is-admin-user($user-id as xs:string) as xs:boolean?

Returns true() if user $user-id has DBA role, false() otherwise.

Parameters:
$user-id The user-id
Returns:
xs:boolean? : true() if user has DBA role, false() otherwise
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:is-dba' instead! This function could be removed in the next major release version.

xmldb:is-authenticated

xmldb:is-authenticated() as xs:boolean

Returns the true() if current user from the xquery context is authenticated, false() otherwise.

Returns:
xs:boolean : true() if user from the xquery context is authenticated, false() otherwise
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:is-authenticated' instead! This function could be removed in the next major release version.

xmldb:last-modified

xmldb:last-modified($collection-uri as item(), $resource as xs:string) as xs:dateTime?

Returns the last-modification date of resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:dateTime? : the last modification date

xmldb:login

xmldb:login($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?) as xs:boolean

Login the user, $user-id, and set it as the owner of the currently executing XQuery. Collection URIs can be specified either as a simple collection path or an XMLDB URI. It returns true if the authentication succeeds, false otherwise. If called from a HTTP context the login is cached for the lifetime of the HTTP session and may be used for any XQuery run in that session. If an HTTP session does not already exist, none will be created.

Parameters:
$collection-uri The collection URI
$user-id? The user-id
$password? The password
Returns:
xs:boolean : true() on successful authentication and owner elevation, false() otherwise

xmldb:login

xmldb:login($collection-uri as xs:string, $user-id as xs:string?, $password as xs:string?, $create-session as xs:boolean?) as xs:boolean

Login the user, $user-id, and set it as the owner of the currently executing XQuery. Collection URIs can be specified either as a simple collection path or an XMLDB URI. It returns true() if the authentication succeeds, false() otherwise. If called from a HTTP context the login is cached for the lifetime of the HTTP session and may be used for any XQueryrun in that session. $create-session specifies whether to create an HTTP session on successful authentication or not. If $create-session is false() or the empty sequence no session will be created if one does not already exist.

Parameters:
$collection-uri The collection URI
$user-id? The user-id
$password? The password
$create-session? whether to create the session or not on successful authentication, default false()
Returns:
xs:boolean : true() on successful authentication and owner elevation, false() otherwise

xmldb:match-collection

xmldb:match-collection($regexp as xs:string) as xs:string*

Looks for collection names in the collection index that match the provided regexp

Parameters:
$regexp The expression to use for matching collection names
Returns:
xs:string* : The names of the collections that match the expression

xmldb:move

xmldb:move($source-collection-uri as xs:string, $target-collection-uri as xs:string) as item()

Moves the collection $source-collection-uri into the collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$source-collection-uri The source collection URI
$target-collection-uri The target collection URI
Returns:
item()

xmldb:move

xmldb:move($source-collection-uri as xs:string, $target-collection-uri as xs:string, $resource as xs:string) as item()

Moves the resource $resource from the collection $source-collection-uri into collection $target-collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$source-collection-uri The source collection URI
$target-collection-uri The target collection URI
$resource The resource
Returns:
item()

xmldb:permissions-to-string

xmldb:permissions-to-string($permissions as xs:integer) as xs:string?

Formats the resource or collection permissions, $permissions, passed as an integer value into a string. The returned string shows the permissions following the Unix conventions, i.e. all permissions set is returned as rwxrwxrwx, where the first three chars are for user permissions, followed by group and other users. 'r' denotes read, 'w' write and 'u' update permissions.

Parameters:
$permissions The permissions in xs:integer format
Returns:
xs:string? : the permissions as string 'rwu' for, user, group and other
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:octal-to-mode' instead! This function could be removed in the next major release version.

xmldb:register-database

xmldb:register-database($driver as xs:string, $create-db as xs:boolean) as xs:boolean

Registers an XMLDB driver class with the XMLDB Database Manager. This is only required if you want to access a database instance different from the one that executes the XQuery.

Parameters:
$driver The DB driver
$create-db The flag to create the db if it does not exist
Returns:
xs:boolean : true() if successfully registered, false() otherwise

xmldb:reindex

xmldb:reindex($collection-uri as xs:string) as xs:boolean

Reindex collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role.

Parameters:
$collection-uri The collection URI
Returns:
xs:boolean : true() if successfully reindexed, false() otherwise

xmldb:reindex

xmldb:reindex($collection-uri as xs:string, $doc-uri as xs:string) as xs:boolean

Reindex document $doc-uri from $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI. The XQuery owner must have appropriate privileges to do this, e.g. having DBA role.

Parameters:
$collection-uri The collection URI
$doc-uri The document URI
Returns:
xs:boolean : true() if successfully reindexed, false() otherwise

xmldb:remove

xmldb:remove($collection-uri as xs:string) as item()

Removes the collection $collection-uri and its contents from the database. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
Returns:
item()

xmldb:remove

xmldb:remove($collection-uri as xs:string, $resource as xs:string) as item()

Removes the resource $resource from the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
item()

xmldb:remove-user-from-group

xmldb:remove-user-from-group($user as xs:string, $group as xs:string) as xs:boolean

Remove a user from a group. $user is the username. $group is the group nameThe XQuery owner must have appropriate privileges to do this, e.g. having DBA role.

Parameters:
$user The user name
$group The group name
Returns:
xs:boolean : true() or false() indicating the outcome of the operation
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:remove-group-member' instead! This function could be removed in the next major release version.

xmldb:rename

xmldb:rename($source-collection-uri as xs:string, $new-collection-name as xs:string) as item()

Renames the collection $source-collection-uri with new name $new-collection-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$source-collection-uri The source collection URI
$new-collection-name The new collection name
Returns:
item()

xmldb:rename

xmldb:rename($collection-uri as xs:string, $resource as xs:string, $new-resource-name as xs:string) as item()

Renames the resource $resource in collection $collection-uri with new name $new-resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
$new-resource-name The new resource name
Returns:
item()

xmldb:set-collection-permissions

xmldb:set-collection-permissions($collection-uri as xs:string, $user-id as xs:string, $group-id as xs:string, $permissions as xs:integer) as item()

Sets the permissions of the collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $user-id specifies the user which will become the owner of the resource, $group-id the group, and $permissons the permissions as an xs:integer value. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience.

Parameters:
$collection-uri The collection URI
$user-id The user-id
$group-id The group-id
$permissions The permissions
Returns:
item()
Deprecated:
You should use sm:chown and sm:chmod from the SecurityManager Module instead. This function could be removed in the next major release version.

xmldb:set-mime-type

xmldb:set-mime-type($resource-uri as xs:anyURI, $mime-type as xs:string?) as empty-sequence()

Set the MIME type of the resource $resource-uri.Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.

Parameters:
$resource-uri The resource URI
$mime-type? The new mime-type, use empty sequence to set default value.
Returns:
empty-sequence()

xmldb:set-resource-permissions

xmldb:set-resource-permissions($collection-uri as xs:string, $resource as xs:string, $user-id as xs:string, $group-id as xs:string, $permissions as xs:integer) as item()

Sets the permissions of the resource $resource in collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI. $user-id specifies the user which will become the owner of the resource, $group-id the group, and $permissions the permissions as an xs:integer value. PLEASE REMEMBER that octal number 0755 is 7*64+5*8+5 i.e. 493 in decimal NOT 755. You can use util:base-to-integer(0755, 8) as argument for convenience.

Parameters:
$collection-uri The collection URI
$resource The resource
$user-id The user-id
$group-id The group-id
$permissions The permissions
Returns:
item()
Deprecated:
You should use sm:chown and sm:chmod from the SecurityManager Module instead. This function could be removed in the next major release version.

xmldb:size

xmldb:size($collection-uri as xs:string, $resource as xs:string) as xs:long

Returns the estimated size of the resource $resource (in bytes) in the collection $collection-uri. The estimation is based on the number of pages occupied by the resource. If the document is serialized back to a string, its size may be different, since parts of the structural information are stored in compressed form. Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uri The collection URI
$resource The resource
Returns:
xs:long : the size of the pages, occupied by the resource, in bytes

xmldb:store

xmldb:store($collection-uri as xs:string, $resource-name as xs:string?, $contents as item()) as xs:string?

Stores a new resource into the database. The resource is stored in the collection $collection-uri with the name $resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The contents $contents, is either a node, an xs:string, a Java file object or an xs:anyURI. A node will be serialized to SAX. It becomes the root node of the new document. If $contents is of type xs:anyURI, the resource is loaded from that URI. Returns the path to the new document if successfully stored, otherwise an XPathException is thrown.

Parameters:
$collection-uri The collection URI
$resource-name? The resource name
$contents The contents
Returns:
xs:string? : the path to new resource if sucessfully stored, otherwise the emtpty sequence

xmldb:store

xmldb:store($collection-uri as xs:string, $resource-name as xs:string?, $contents as item(), $mime-type as xs:string) as xs:string?

Stores a new resource into the database. The resource is stored in the collection $collection-uri with the name $resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The contents $contents, is either a node, an xs:string, a Java file object or an xs:anyURI. A node will be serialized to SAX. It becomes the root node of the new document. If $contents is of type xs:anyURI, the resource is loaded from that URI. The final argument $mime-type is used to specify a mime type. If the mime-type is not a xml based type, the resource will be stored as a binary resource.Returns the path to the new document if successfully stored, otherwise an XPathException is thrown.

Parameters:
$collection-uri The collection URI
$resource-name? The resource name
$contents The contents
$mime-type The mime type
Returns:
xs:string? : the path to new resource if sucessfully stored, otherwise the emtpty sequence

xmldb:store-as-binary

xmldb:store-as-binary($collection-uri as xs:string, $resource-name as xs:string?, $contents as item()) as xs:string?

Stores a new resource into the database. The resource is stored in the collection $collection-uri with the name $resource-name. Collection URIs can be specified either as a simple collection path or an XMLDB URI. The contents $contents, is either a node, an xs:string, a Java file object or an xs:anyURI. A node will be serialized to SAX. It becomes the root node of the new document. If $contents is of type xs:anyURI, the resource is loaded from that URI. Returns the path to the new document if successfully stored, otherwise an XPathException is thrown.

Parameters:
$collection-uri The collection URI
$resource-name? The resource name
$contents The contents
Returns:
xs:string? : the path to new resource if sucessfully stored, otherwise the emtpty sequence

xmldb:store-files-from-pattern

xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+) as xs:string*

Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s).

Parameters:
$collection-uri The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directory The directory in the file system from where the files are read.
$pattern+ The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one
Returns:
xs:string* : the sequence of document paths

xmldb:store-files-from-pattern

xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+, $mime-type as xs:string?) as xs:string*

Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s).

Parameters:
$collection-uri The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directory The directory in the file system from where the files are read.
$pattern+ The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one
$mime-type? If the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource.
Returns:
xs:string* : the sequence of document paths

xmldb:store-files-from-pattern

xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+, $mime-type as xs:string?, $preserve-structure as xs:boolean) as xs:string*

Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s).

Parameters:
$collection-uri The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directory The directory in the file system from where the files are read.
$pattern+ The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one
$mime-type? If the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource.
$preserve-structure If preserve-structure is true(), the filesystem directory structure will be mirrored in the collection. Otherwise all the matching resources, including the ones in sub-directories, will be stored in the collection given in the first argument flatly.
Returns:
xs:string* : the sequence of document paths

xmldb:store-files-from-pattern

xmldb:store-files-from-pattern($collection-uri as xs:string, $directory as xs:string, $pattern as xs:string+, $mime-type as xs:string?, $preserve-structure as xs:boolean, $exclude as xs:string*) as xs:string*

Stores new resources into the database. Resources are read from the server's file system, using file patterns. The function returns a sequence of all document paths added to the db. These can be directly passed to fn:doc() to retrieve the document(s).

Parameters:
$collection-uri The collection-uri where resources should be stored. Collection URIs can be specified either as a simple collection path or an XMLDB URI.
$directory The directory in the file system from where the files are read.
$pattern+ The file matching pattern. Based on code from Apache's Ant, thus following the same conventions. For example: *.xml matches any file ending with .xml in the current directory, **/*.xml matches files in any directory below the current one
$mime-type? If the mime-type is something other than 'text/xml' or 'application/xml', the resource will be stored as a binary resource.
$preserve-structure If preserve-structure is true(), the filesystem directory structure will be mirrored in the collection. Otherwise all the matching resources, including the ones in sub-directories, will be stored in the collection given in the first argument flatly.
$exclude* A sequence of file patterns to exclude
Returns:
xs:string* : the sequence of document paths

xmldb:string-to-permissions

xmldb:string-to-permissions($permissions-string as xs:string) as xs:integer

Converts the resource or collection permissions, $permissions-string, into an integer representation suitable for use with set-permissions functions. The permissions string should be in the format 'rwxrwxrwx' where r is read, w is write and u is update.

Parameters:
$permissions-string The permissions string
Returns:
xs:integer : The permissions integer
Deprecated:
Moved to the module: http://exist-db.org/xquery/securitymanager, you should now use 'sm:mode-to-octal' instead! This function could be removed in the next major release version.

xmldb:touch

xmldb:touch($collection-uri as xs:string, $resource as xs:string) as xs:boolean

Sets the modification time of a resource to the current system time. If not resource does not exist it is not created.

Parameters:
$collection-uri The collection URI
$resource The name of the resource in the collection
Returns:
xs:boolean : true if the modification time was updated, false otherwise.

xmldb:touch

xmldb:touch($collection-uri as xs:string, $resource as xs:string, $modification-time as xs:dateTime) as xs:boolean

Sets the modification time of a resource. If not resource does not exist it is not created.

Parameters:
$collection-uri The collection URI
$resource The name of the resource in the collection
$modification-time The modification time to set on the resource
Returns:
xs:boolean : true if the modification time was updated, false otherwise.

xmldb:update

xmldb:update($collection-uri as xs:string, $modifications as node()) as xs:integer

Processes an XUpdate request, $modifications, against a collection $collection-uri. Collection URIs can be specified either as a simple collection path or an XMLDB URI.The modifications are passed in a document conforming to the XUpdate specification. http://rx4rdf.liminalzone.org/xupdate-wd.html#N1a32e0The function returns the number of modifications caused by the XUpdate.

Parameters:
$collection-uri The collection URI
$modifications The XUpdate modifications to be processed
Returns:
xs:integer : the number of modifications, as xs:integer, caused by the XUpdate

xmldb:xcollection

xmldb:xcollection($collection-uris as xs:string+) as node()*

Returns the document nodes in the collections $collection-uris non-recursively, i.e. does not include document nodes found in sub-collections. C.f. fn:collection(). Collection URIs can be specified either as a simple collection path or an XMLDB URI.

Parameters:
$collection-uris+ The collection URIs
Returns:
node()* : the document nodes from the specified collections excluding sub-collections