Difference between revisions of "Client Module"
Jump to navigation
Jump to search
(Fixed parameter name) |
|||
Line 1: | Line 1: | ||
− | This [[Module Library|XQuery Module]] contains functions to access remote BaseX server instances from XQuery. With this module, you can on the one hand execute database commands and on the other hand | + | This [[Module Library|XQuery Module]] contains functions to access remote BaseX server instances from XQuery. With this module, you can on the one hand execute database commands and on the other hand evaluate queries, the results of which are returned as XDM sequences. |
+ | |||
+ | =Conventions= | ||
+ | |||
+ | All functions are assigned to the <code>http://basex.org/modules/client</code> namespace, which is statically bound to the <code>client</code> prefix.<br/> | ||
+ | Errors are assigned to the <code>http://basex.org/errors</code> namespace, which is statically bound to the <code>bxerr</code> prefix. | ||
=Functions= | =Functions= |
Revision as of 19:40, 25 May 2012
This XQuery Module contains functions to access remote BaseX server instances from XQuery. With this module, you can on the one hand execute database commands and on the other hand evaluate queries, the results of which are returned as XDM sequences.
Contents
Conventions
All functions are assigned to the http://basex.org/modules/client
namespace, which is statically bound to the client
prefix.
Errors are assigned to the http://basex.org/errors
namespace, which is statically bound to the bxerr
prefix.
Functions
client:connect
Signatures | client:connect($host as xs:string, $port as xs:integer, $user as xs:string, $password as xs:string) as xs:anyURI |
Summary | This function establishes a connection to a remote BaseX server, creates a new client session, and returns a session id. The parameter $host is the name of the database server, $port specifies the server port, and $user and $password represent the login data.
|
client:execute
Signatures | client:execute($id as xs:anyURI, $command as xs:string) as xs:string
|
Summary | This function executes a database command and returns the result as string. The parameter $id contains the session id returned by client:connect(). The $command represents the database command string, which will be executed by the server.
|
Examples | The following query creates a new database TEST on a remote BaseX server:
let $c := client:connect('basex.server.org', 8080, 'admin', 'admin') return client:execute($c, 'create database TEST') |
client:query
Signatures | client:query($id as xs:anyURI, $query as xs:string) as item()*
|
Summary | This function evaluates a query and returns the result as sequence. The parameter $id contains the session id returned by client:connect(), and $query represents the query string, which will be evaluated by the server.
|
Examples | The following query performs a query on a first server, the results of which are passed on to a second server:
let $c1 := client:connect('server1.basex.org', 8080, 'jack', 'C0S19tt2X') let $c2 := client:connect('server2.basex.org', 8080, 'john', '465wFHe26') return for $c in client:query($c1, '1 to 10') return client:query($c1, $c || '* 2') |
client:close
Signatures | client:close($id as xs:anyURI) as empty-sequence()
|
Summary | This function closes a client session. $id specifies the session id.
|
Errors
- BXCL0001 is raised if a connection error occurs (e.g., if the addressed server is not available).
- BXCL0002 is raised if the specified session id is unknown.
- BXCL0003 is raised if an error occurs while executing the command.
Changelog
The module was introduced with Version 7.2.2.