Difference between revisions of "Database Module"
Jump to navigation
Jump to search
m (Text replace - "www.basex.org" to "basex.org") |
|||
Line 1: | Line 1: | ||
This module contains [[Querying#Functions|XQuery functions]] for handling databases from within XQuery. Existing databases can be opened and listed, index structures can be directly accessed, documents can be added to and removed from collections, etc. All functions are introduced with the {{Mono|db:}} prefix, which is linked to the statically declared {{Mono|http://basex.org/modules/db}} namespace. | This module contains [[Querying#Functions|XQuery functions]] for handling databases from within XQuery. Existing databases can be opened and listed, index structures can be directly accessed, documents can be added to and removed from collections, etc. All functions are introduced with the {{Mono|db:}} prefix, which is linked to the statically declared {{Mono|http://basex.org/modules/db}} namespace. | ||
− | + | This preview page contains all commands offered by the [http://files.basex.org/releases/latest/ latest stable snapshot]. | |
+ | There is also [[Database Module|another page]], which lists the functions of the current release. | ||
+ | |||
+ | =Commonalities= | ||
+ | |||
+ | Many functions share {{Mono|$db}} as argument, which may either reference a string, denoting the name of the addressed database, or a node from an already opened database. The following errors may be raised by these functions: | ||
+ | |||
+ | * '''[[XQuery Errors#BaseX Errors|BASX0002]]''' is raised if {{Mono|$db}} references a node that is not stored in a database (i.e., references a main-memory XML fragment). | ||
+ | * '''[[XQuery Errors#BaseX Errors|BASX0003]]''' is raised if the addressed database cannot be opened. | ||
=General Functions= | =General Functions= | ||
Line 9: | Line 17: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:info'''($db as item()) as element(Database)}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns information on | + | |Returns meta information on the specified database. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
Line 26: | Line 27: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:list'''() as xs:string*}}<br/>{{Mono|'''db:list'''($db as item()) as xs:string*}}<br/>{{Mono|'''db:list'''($db as item(), $path as xs:string) as xs:string*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns an {{Mono|xs:string}} sequence with the names of all databases. If {{Mono|$db}} is specified, all documents and raw files of the specified database are returned. The list of resources can be further restricted by the {{Mono|$path}} argument. | + | |Returns an {{Mono|xs:string}} sequence with the names of all databases.<br/>If {{Mono|$db}} is specified, all documents and raw files of the specified database are returned.<br/>The list of resources can be further restricted by the {{Mono|$path}} argument. |
− | |||
− | |||
− | |||
|} | |} | ||
Line 39: | Line 37: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:open'''($db as item()) as document-node()*}}<br />{{Mono|'''db:open'''($db as item(), $path as xs:string) as document-node()*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns a sequence with all document nodes contained in the database specified by {{Mono|$db}}. The returned | + | |Returns a sequence with all document nodes contained in the database specified by {{Mono|$db}}.<br/>The document nodes to be returned can be restricted by the {{Mono|$path}} argument. |
− | |||
− | |||
− | |||
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 57: | Line 52: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:open-id'''($db as item(), $id as xs:integer) as node()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Opens the database specified by {{Mono|$db}} and returns the node with the specified {{Mono|$id}} value.<br /> | + | |Opens the database specified by {{Mono|$db}} and returns the node with the specified {{Mono|$id}} value.<br />Each database node has a persistent ''id'', which remains valid after update operations. If no updates are performed, the ''pre'' value can be requested, which provides access to database nodes in constant time. |
− | |||
− | |||
− | |||
|} | |} | ||
Line 70: | Line 62: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:open-pre'''($db as item(), $pre as xs:integer) as node()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Opens the database specified by {{Mono|$db}} and returns the node with the specified {{Mono|$pre}} value. | + | |Opens the database specified by {{Mono|$db}} and returns the node with the specified {{Mono|$pre}} value.<br />The ''pre'' value provides access to a database node in constant time, but it is ''transient'', i.e., it may change when database updates are performed. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0004]]''' is raised if the specified {{Mono|$pre}} value does not exist in the database. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| | | | ||
− | * {{Mono|db:open-pre("docs", 0)}} returns the first | + | * {{Mono|db:open-pre("docs", 0)}} returns the first database node from the database named {{Mono|docs}}. |
|} | |} | ||
Line 87: | Line 79: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:system'''() as element(System)}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Returns information on the database system, such as the database path and current database settings. |
|} | |} | ||
Line 99: | Line 91: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:attribute'''($db as item(), $string as item()) as attribute()*}}<br/>{{Mono|'''db:attribute'''($db as item(), $string as item(), $attname as xs:string) as attribute()*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
Line 113: | Line 105: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:fulltext'''($db as item(), $text as item()) as text()*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns all text nodes from the full-text index that contain the string {{Mono|$text}}. The index full-text options | + | |Returns all text nodes from the full-text index that contain the string {{Mono|$text}}.<br/>The index full-text options will be applied here: if the index terms have been stemmed, the search string will be stemmed as well. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0001]]''' is raised if the index is not available. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 130: | Line 122: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:node-id'''($nodes as node()*) as xs:integer*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns the | + | |Returns the ''id'' values of all database nodes specified by {{Mono|$nodes}}.<br/>Each database node has a persistent ''id'', which remains valid after update operations. If no updates are performed, the ''pre'' value can be requested, which provides access to database nodes in constant time. |
|} | |} | ||
Line 140: | Line 132: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:node-pre'''($nodes as node()*) as xs:integer*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Returns the | + | |Returns the ''pre'' values of all database nodes specified by {{Mono|$nodes}}.<br/>The ''pre'' value provides access to a database node in constant time, but it is ''transient'', i.e., it may change when database updates are performed. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 152: | Line 144: | ||
==db:retrieve== | ==db:retrieve== | ||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:retrieve'''($db as item(), $path as xs:string) as xs:base64Binary}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Returns a binary database resource addressed by {{Mono|$db}} and {{Mono|$path}}. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#Functions Errors|FODC0002]]''' is raised if the addressed resource is not found or cannot be retrieved. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 173: | Line 164: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:text'''($db as item(), $string as item()) as text()*}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
Line 186: | Line 177: | ||
==db:add== | ==db:add== | ||
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:add'''($db as item(), $input as item()) as empty-sequence()}}<br/>{{Mono|'''db:add'''($db as item(), $input as item(), $path as xs:string) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Adds documents specified by {{Mono|$input}} to the database {{Mono|$db}} and the specified {{Mono|$path}}. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#Functions Errors|FODC0002]]''' is raised if {{Mono|$input}} is a string representing a path, which cannot be read.<br/>'''[[XQuery Errors#Update Errors|FOUP0001]]''' is raised if {{Mono|$input}} is not a string and not a document node. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 212: | Line 201: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:delete'''($db as item(), $path as xs:string) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Deletes document(s), specified by {{Mono|$path}}, from the database {{Mono|$db}}. |
− | |||
− | |||
− | |||
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 230: | Line 216: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:optimize'''($db as item()) as empty-sequence()}}<br/>{{Mono|'''db:optimize'''($db as item(), $all as xs:boolean) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Optimizes the meta data and indexes of the database {{Mono|$db}}.<br/>If {{Mono|$all}} is set to {{Mono|true()}}, the complete database will be rebuilt. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0014]]''' is raised if an error occurs during optimizing the data structures.<br/>'''[[XQuery Errors#BaseX Errors|BASX0015]]''' is raised if the {{Mono|$all}} flag is set to {{Mono|true()}}, but the database is an in-memory database.<br/>'''[[XQuery Errors#BaseX Errors|BASX0016]]''' is raised if the database {{Mono|$db}} is in use by other user(s). |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 248: | Line 234: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:rename'''($db as item(), $path as xs:string, $newpath as xs:string) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Renames document(s), specified by {{Mono|$path}} to {{Mono|$newpath}} in the database {{Mono|$db}}. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0013]]''' is raised if new document name(s) will be empty. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 266: | Line 252: | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:replace'''($db as item(), $path as xs:string, $input as item()) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Replaces a document, specified by {{Mono|$path}}, in the database {{Mono|$db}} with the content of {{Mono|$input}}. |
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0012]]''' is raised if {{Mono|$path}} is not a single document path.<br/>'''[[XQuery Errors#Functions Errors|FODC0002]]''' is raised if {{Mono|$input}} is a string representing a path, which cannot be read.<br/>'''[[XQuery Errors#Update Errors|FOUP0001]]''' is raised if {{Mono|$input}} is not a string and not a document node. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 282: | Line 268: | ||
==db:store== | ==db:store== | ||
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:store'''($db as item(), $path as xs:string, $data as item()) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
Line 293: | Line 277: | ||
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
− | | | + | |'''[[XQuery Errors#Update Errors|FOUP0002]]''' is raised if the resource cannot be stored at the specified location. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
Line 302: | Line 286: | ||
=Helper Functions= | =Helper Functions= | ||
− | ==db: | + | ==db:exists== |
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:exists'''($db as item()) as xs:boolean}}<br/>{{Mono|'''db:exists'''($db as item(), $path as xs:string) as xs:boolean}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Checks if the specified database or resource exists. {{Mono|false}} is returned if a database directory is specified. |
− | |||
− | |||
− | |||
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| | | | ||
− | * {{Mono|db: | + | * {{Mono|db:exists("DB")}} returns {{Mono|true}} if the database {{Mono|DB}} exists. |
− | + | * {{Mono|db:exists("DB", "resource")}} returns {{Mono|true}} if {{Mono|resource}} is an XML document or a raw file. | |
− | * {{Mono|db: | ||
|} | |} | ||
− | ==db: | + | ==db:is-raw== |
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:is-raw'''($db as item(), $path as xs:string) as xs:boolean}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Checks if the specified resource exists and if it is a raw file. |
|- | |- | ||
− | | valign='top' | ''' | + | | valign='top' | '''Examples''' |
− | | | + | | |
+ | * {{Mono|db:is-raw("DB", "music/01.mp3")}} returns {{Mono|true}}. | ||
|} | |} | ||
− | ==db: | + | ==db:is-xml== |
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:is-xml'''($db as item(), $path as xs:string) as xs:boolean}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | |Checks if the specified | + | |Checks if the specified resource exists and if it is an XML document. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| | | | ||
− | * {{Mono|db: | + | * {{Mono|db:is-xml("DB", "dir/doc.xml")}} returns {{Mono|true}}. |
− | |||
|} | |} | ||
− | ==db: | + | ==db:content-type== |
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:content-type'''($db as item(), $path as xs:string) as xs:string}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Retrieves the content type of the resource specified by {{Mono|$path}}.<br/>The file extension is used to recognize the content-type of a resource stored in the database. Content-type {{Mono|application/xml}} will be returned for any XML document stored in the database, regardless of its file name extension. |
+ | |- | ||
+ | | valign='top' | '''Errors''' | ||
+ | |'''[[XQuery Errors#Functions Errors|FODC0002]]''' is raised if the addressed resource is not found or cannot be retrieved. | ||
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| | | | ||
− | * {{Mono|db:is- | + | * {{Mono|db:content-type("DB", "docs/doc01.pdf")}} returns {{Mono|application/pdf}}. |
+ | * {{Mono|db:content-type("DB", "docs/doc01.xml")}} returns {{Mono|application/xml}}. | ||
+ | * {{Mono|db:content-type("DB", "docs/doc01")}} returns {{Mono|application/xml}}, if {{Mono|db:is-xml("DB", "docs/doc01")}} returns {{Mono|true}}. | ||
|} | |} | ||
− | ==db: | + | ==db:event== |
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| valign='top' width='90' | '''Signatures''' | | valign='top' width='90' | '''Signatures''' | ||
− | |{{Mono| | + | |{{Mono|'''db:event'''($name as xs:string, $query as item()) as empty-sequence()}} |
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
− | | | + | |Executes a {{Mono|$query}} and sends the resulting value to all clients watching the [[Events|Event]] with the specified {{Mono|$name}}. The query may also perform updates; no event will be sent to the client that fired the event. |
|- | |- | ||
− | | valign='top' | ''' | + | | valign='top' | '''Errors''' |
− | | | + | |'''[[XQuery Errors#BaseX Errors|BASX0009]]''' is raised if the specified event is unknown.<br/>'''[[XQuery_Errors#Serialization_Errors|SEPM0016]]''' is raised if serialization errors occurred while sending the value.<br/> |
− | |||
|} | |} | ||
+ | |||
+ | =Recent Changes= | ||
+ | |||
+ | ==Version 7.1== | ||
+ | |||
+ | * Added: {{Mono|db:list-details()}}, {{Mono|db:content-type()}} | ||
+ | * Modified: {{Mono|db:info()}}, {{Mono|db:system()}}, {{Mono|db:retrieve()}} | ||
+ | |||
+ | ==Version 7.0== | ||
+ | |||
+ | * Added: {{Mono|db:retrieve()}}, {{Mono|db:store()}}, {{Mono|db:exists()}}, {{Mono|db:is-raw()}}, {{Mono|db:is-xml()}} | ||
+ | * Modified: {{Mono|db:list()}}, {{Mono|db:open()}}, {{Mono|db:add()}} | ||
[[Category:XQuery]] | [[Category:XQuery]] |
Revision as of 05:45, 7 February 2012
This module contains XQuery functions for handling databases from within XQuery. Existing databases can be opened and listed, index structures can be directly accessed, documents can be added to and removed from collections, etc. All functions are introduced with the db:
prefix, which is linked to the statically declared http://basex.org/modules/db
namespace.
This preview page contains all commands offered by the latest stable snapshot. There is also another page, which lists the functions of the current release.
Contents
Commonalities
Many functions share $db
as argument, which may either reference a string, denoting the name of the addressed database, or a node from an already opened database. The following errors may be raised by these functions:
- BASX0002 is raised if
$db
references a node that is not stored in a database (i.e., references a main-memory XML fragment). - BASX0003 is raised if the addressed database cannot be opened.
General Functions
db:info
Signatures | db:info($db as item()) as element(Database)
|
Summary | Returns meta information on the specified database. |
db:list
Signatures | db:list() as xs:string* db:list($db as item()) as xs:string* db:list($db as item(), $path as xs:string) as xs:string*
|
Summary | Returns an xs:string sequence with the names of all databases.If $db is specified, all documents and raw files of the specified database are returned.The list of resources can be further restricted by the $path argument.
|
db:open
Signatures | db:open($db as item()) as document-node()* db:open($db as item(), $path as xs:string) as document-node()*
|
Summary | Returns a sequence with all document nodes contained in the database specified by $db .The document nodes to be returned can be restricted by the $path argument.
|
Examples |
|
db:open-id
Signatures | db:open-id($db as item(), $id as xs:integer) as node()
|
Summary | Opens the database specified by $db and returns the node with the specified $id value.Each database node has a persistent id, which remains valid after update operations. If no updates are performed, the pre value can be requested, which provides access to database nodes in constant time. |
db:open-pre
Signatures | db:open-pre($db as item(), $pre as xs:integer) as node()
|
Summary | Opens the database specified by $db and returns the node with the specified $pre value.The pre value provides access to a database node in constant time, but it is transient, i.e., it may change when database updates are performed. |
Errors | BASX0004 is raised if the specified $pre value does not exist in the database.
|
Examples |
|
db:system
Signatures | db:system() as element(System)
|
Summary | Returns information on the database system, such as the database path and current database settings. |
Read Operations
db:attribute
Signatures | db:attribute($db as item(), $string as item()) as attribute()* db:attribute($db as item(), $string as item(), $attname as xs:string) as attribute()*
|
Summary | Returns all attribute nodes that have $string as their string value.If $attname is specified, the resulting attribute nodes are filtered by their attribute name.
|
Examples |
|
db:fulltext
Signatures | db:fulltext($db as item(), $text as item()) as text()*
|
Summary | Returns all text nodes from the full-text index that contain the string $text .The index full-text options will be applied here: if the index terms have been stemmed, the search string will be stemmed as well. |
Errors | BASX0001 is raised if the index is not available. |
Examples |
|
db:node-id
Signatures | db:node-id($nodes as node()*) as xs:integer*
|
Summary | Returns the id values of all database nodes specified by $nodes .Each database node has a persistent id, which remains valid after update operations. If no updates are performed, the pre value can be requested, which provides access to database nodes in constant time. |
db:node-pre
Signatures | db:node-pre($nodes as node()*) as xs:integer*
|
Summary | Returns the pre values of all database nodes specified by $nodes .The pre value provides access to a database node in constant time, but it is transient, i.e., it may change when database updates are performed. |
Examples |
|
db:retrieve
Signatures | db:retrieve($db as item(), $path as xs:string) as xs:base64Binary
|
Summary | Returns a binary database resource addressed by $db and $path .
|
Errors | FODC0002 is raised if the addressed resource is not found or cannot be retrieved. |
Examples |
|
db:text
Signatures | db:text($db as item(), $string as item()) as text()*
|
Summary | Returns all text nodes that have $string as their string value.
|
Examples |
|
Updates
db:add
Signatures | db:add($db as item(), $input as item()) as empty-sequence() db:add($db as item(), $input as item(), $path as xs:string) as empty-sequence()
|
Summary | Adds documents specified by $input to the database $db and the specified $path .
|
Errors | FODC0002 is raised if $input is a string representing a path, which cannot be read.FOUP0001 is raised if $input is not a string and not a document node.
|
Examples |
|
db:delete
Signatures | db:delete($db as item(), $path as xs:string) as empty-sequence()
|
Summary | Deletes document(s), specified by $path , from the database $db .
|
Examples |
|
db:optimize
Signatures | db:optimize($db as item()) as empty-sequence() db:optimize($db as item(), $all as xs:boolean) as empty-sequence()
|
Summary | Optimizes the meta data and indexes of the database $db .If $all is set to true() , the complete database will be rebuilt.
|
Errors | BASX0014 is raised if an error occurs during optimizing the data structures. BASX0015 is raised if the $all flag is set to true() , but the database is an in-memory database.BASX0016 is raised if the database $db is in use by other user(s).
|
Examples |
|
db:rename
Signatures | db:rename($db as item(), $path as xs:string, $newpath as xs:string) as empty-sequence()
|
Summary | Renames document(s), specified by $path to $newpath in the database $db .
|
Errors | BASX0013 is raised if new document name(s) will be empty. |
Examples |
|
db:replace
Signatures | db:replace($db as item(), $path as xs:string, $input as item()) as empty-sequence()
|
Summary | Replaces a document, specified by $path , in the database $db with the content of $input .
|
Errors | BASX0012 is raised if $path is not a single document path.FODC0002 is raised if $input is a string representing a path, which cannot be read.FOUP0001 is raised if $input is not a string and not a document node.
|
Examples |
|
db:store
Signatures | db:store($db as item(), $path as xs:string, $data as item()) as empty-sequence()
|
Summary | Stores a binary resource specified by $data at the location specified by $path .
|
Errors | FOUP0002 is raised if the resource cannot be stored at the specified location. |
Examples |
|
Helper Functions
db:exists
Signatures | db:exists($db as item()) as xs:boolean db:exists($db as item(), $path as xs:string) as xs:boolean
|
Summary | Checks if the specified database or resource exists. false is returned if a database directory is specified.
|
Examples |
|
db:is-raw
Signatures | db:is-raw($db as item(), $path as xs:string) as xs:boolean
|
Summary | Checks if the specified resource exists and if it is a raw file. |
Examples |
|
db:is-xml
Signatures | db:is-xml($db as item(), $path as xs:string) as xs:boolean
|
Summary | Checks if the specified resource exists and if it is an XML document. |
Examples |
|
db:content-type
Signatures | db:content-type($db as item(), $path as xs:string) as xs:string
|
Summary | Retrieves the content type of the resource specified by $path .The file extension is used to recognize the content-type of a resource stored in the database. Content-type application/xml will be returned for any XML document stored in the database, regardless of its file name extension.
|
Errors | FODC0002 is raised if the addressed resource is not found or cannot be retrieved. |
Examples |
|
db:event
Signatures | db:event($name as xs:string, $query as item()) as empty-sequence()
|
Summary | Executes a $query and sends the resulting value to all clients watching the Event with the specified $name . The query may also perform updates; no event will be sent to the client that fired the event.
|
Errors | BASX0009 is raised if the specified event is unknown. SEPM0016 is raised if serialization errors occurred while sending the value. |
Recent Changes
Version 7.1
- Added:
db:list-details()
,db:content-type()
- Modified:
db:info()
,db:system()
,db:retrieve()
Version 7.0
- Added:
db:retrieve()
,db:store()
,db:exists()
,db:is-raw()
,db:is-xml()
- Modified:
db:list()
,db:open()
,db:add()