Difference between revisions of "Database Module"
Line 3: | Line 3: | ||
=Conventions= | =Conventions= | ||
− | All functions in this module are assigned to the | + | All functions in this module are assigned to the {{Code|http://basex.org/modules/db}} namespace, which is statically bound to the {{Code|db}} prefix.<br/> |
− | All errors are assigned to the | + | All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix. |
==Database Nodes== | ==Database Nodes== | ||
Line 10: | Line 10: | ||
Many function signatures in this and other modules share {{Code|$db}} as argument to reference an existing database. The argument may either be a string, denoting the name of the addressed database, or a single node from an already opened database. The following errors may be raised by these functions: | Many function signatures in this and other modules share {{Code|$db}} as argument to reference an existing database. The argument may either be a string, denoting the name of the addressed database, or a single node from an already opened database. The following errors may be raised by these functions: | ||
− | * | + | * {{Error|BXDB0001|#Errors}} {{Code|$db}} references an XML node that is not stored in a database, or is no database fragment. |
− | * | + | * {{Error|BXDB0002|#Errors}} the addressed database cannot be opened. |
Last not but least, the argument may also reference a BaseX-specific ''database fragment''. All XML fragments can be converted to database fragments by applying the [[XQuery_Update#transform|transform]] expression on an XML fragment: | Last not but least, the argument may also reference a BaseX-specific ''database fragment''. All XML fragments can be converted to database fragments by applying the [[XQuery_Update#transform|transform]] expression on an XML fragment: | ||
Line 27: | Line 27: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:info|$db as item()|element(Database)}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 37: | Line 37: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:list||xs:string*}}<br/>{{Func|db:list|$db as item()|xs:string*}}<br/>{{Func|db:list|$db as item(), $path as xs:string|xs:string*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 51: | Line 51: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:list-details||element(database)*}}<br/>{{Func|db:list-details|$db as item()|element(resource)*}}<br/>{{Func|db:list-details|$db as item(), $path as xs:string|element(resource)*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 65: | Line 65: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:open|$db as item()|document-node()*}}<br />{{Func|db:open|$db as item(), $path as xs:string|document-node()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 80: | Line 80: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:open-id|$db as item(), $id as xs:integer|node()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 86: | Line 86: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0009|XQuery Errors#BaseX Errors}} the specified id value does not exist in the database. |
|} | |} | ||
Line 93: | Line 93: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:open-pre|$db as item(), $pre as xs:integer|node()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 99: | Line 99: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0009|XQuery Errors#BaseX Errors}} the specified pre value does not exist in the database. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 110: | Line 110: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:system||element(system)}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 122: | Line 122: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:attribute|$db as item(), $string as item()|attribute()*}}<br/>{{Func|db:attribute|$db as item(), $string as item(), $attname as xs:string|attribute()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 138: | Line 138: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:attribute-range|$db as item(), $min as xs:string, $max as xs:string|text()*}}<br/>{{Func|db:attribute-range|$db as item(), $min as xs:string, $max as xs:string, $attname as xs:string|attribute()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 152: | Line 152: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:fulltext|$db as item(), $terms as xs:string|text()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 158: | Line 158: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0004|#Errors}} the full-text index is not available. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 169: | Line 169: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:node-id|$nodes as node()*|xs:integer*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 179: | Line 179: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:node-pre|$nodes as node()*|xs:integer*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 194: | Line 194: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:retrieve|$db as item(), $path as xs:string|xs:base64Binary}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 200: | Line 200: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0003|#Errors}} the databse is not ''persistent'' (stored on disk).<br/>{{Error|FODC0002|XQuery Errors#Functions Errors}} the addressed resource cannot be retrieved.<br/>{{Error|FODC0007|XQuery Errors#Functions Errors}} the specified path is invalid. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 211: | Line 211: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:text|$db as item(), $string as item()|text()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 227: | Line 227: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:text-range|$db as item(), $min as xs:string, $max as xs:string|text()*}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 246: | Line 246: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:add|$db as item(), $input as item()|empty-sequence()}}<br/>{{Func|db:add|$db as item(), $input as item(), $path as xs:string|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 252: | Line 252: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|FODC0002|XQuery Errors#Functions Errors}} {{Code|$input}} is a string representing a path, which cannot be read.<br/>{{Error|FOUP0001|XQuery Errors#Update Errors}} {{Code|$input}} is neither string nor a document node. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 266: | Line 266: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:delete|$db as item(), $path as xs:string|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 281: | Line 281: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:optimize|$db as item()|empty-sequence()}}<br/>{{Func|db:optimize|$db as item(), $all as xs:boolean|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 287: | Line 287: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BASX0014|XQuery Errors#BaseX Errors}} an error occurs during optimizing the data structures.<br/>{{Error|BASX0015|XQuery Errors#BaseX Errors}} the {{Code|$all}} flag is set to {{Code|true()}}, but the database is an in-memory database.<br/>{{Error|BASX0016|XQuery Errors#BaseX Errors}} the database {{Code|$db}} is in use by other user(s). |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 299: | Line 299: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:rename|$db as item(), $path as xs:string, $newpath as xs:string|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 305: | Line 305: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0008|#Errors}} new document names would be empty. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 317: | Line 317: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:replace|$db as item(), $path as xs:string, $input as item()|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 323: | Line 323: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0006|#Errors}} {{Code|$path}} is not a single document path.<br/>{{Error|FODC0002|XQuery Errors#Functions Errors}} {{Code|$input}} is a string representing a path, which cannot be read.<br/>{{Error|FOUP0001|XQuery Errors#Update Errors}} {{Code|$input}} is neither a string nor a document node. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 336: | Line 336: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:store|$db as item(), $path as xs:string, $data as item()|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 342: | Line 342: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0003|#Errors}} the databse is not ''persistent'' (stored on disk).<br/>{{Error|FODC0007|XQuery Errors#Functions Errors}} the specified path is invalid.<br/>{{Error|FOUP0002|XQuery Errors#Update Errors}} the resource cannot be stored at the specified location. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 355: | Line 355: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:output|$data as item()*|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 371: | Line 371: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:exists|$db as item()|xs:boolean}}<br/>{{Func|db:exists|$db as item(), $path as xs:string|xs:boolean}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 386: | Line 386: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:is-raw|$db as item(), $path as xs:string|xs:boolean}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 400: | Line 400: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:is-xml|$db as item(), $path as xs:string|xs:boolean}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 414: | Line 414: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:content-type|$db as item(), $path as xs:string|xs:string}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 420: | Line 420: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|FODC0002|XQuery Errors#Functions Errors}} the addressed resource is not found or cannot be retrieved. |
|- | |- | ||
| '''Examples''' | | '''Examples''' | ||
Line 433: | Line 433: | ||
|- | |- | ||
| width='90' | '''Signatures''' | | width='90' | '''Signatures''' | ||
− | |{{ | + | |{{Func|db:event|$name as xs:string, $query as item()|empty-sequence()}} |
|- | |- | ||
| '''Summary''' | | '''Summary''' | ||
Line 439: | Line 439: | ||
|- | |- | ||
| '''Errors''' | | '''Errors''' | ||
− | | | + | |{{Error|BXDB0010|XQuery Errors#BaseX Errors}} the specified event is unknown.<br/>{{Error|SEPM0016|XQuery_Errors#Serialization_Errors}} serialization errors occurred while sending the value.<br/> |
|} | |} | ||
Line 448: | Line 448: | ||
! width="95%"|Description | ! width="95%"|Description | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0001}} |
|A referenced XML node is no [[#Database Nodes|database node]], i.e. is neither stored in a database nor a database fragment. | |A referenced XML node is no [[#Database Nodes|database node]], i.e. is neither stored in a database nor a database fragment. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0002}} |
|An I/O error occurred while opening a database. | |An I/O error occurred while opening a database. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0003}} |
|The addressed database is not ''persistent'' (stored on disk). | |The addressed database is not ''persistent'' (stored on disk). | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0004}} |
|The database lacks an index structure required by the called function. | |The database lacks an index structure required by the called function. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0005}} |
|A query is expected to exclusively return [[#Database Nodes|database nodes]] of a single database. | |A query is expected to exclusively return [[#Database Nodes|database nodes]] of a single database. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0006}} |
|A database path addressed with {{Code|doc()}} contains more than one document. | |A database path addressed with {{Code|doc()}} contains more than one document. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0007}} |
|A database cannot be updated because it is opened by another process. | |A database cannot be updated because it is opened by another process. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0008}} |
|Database paths cannot be renamed to empty strings. | |Database paths cannot be renamed to empty strings. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0009}} |
|The addressed database id or pre value is out of range. | |The addressed database id or pre value is out of range. | ||
|- | |- | ||
− | | | + | |{{Code|BXDB0010}} |
|The specified event is unknown. | |The specified event is unknown. | ||
|} | |} |
Revision as of 15:48, 26 May 2012
This XQuery Module contains functions for processing databases from within XQuery. Existing databases can be opened and listed, its contents can be directly accessed, documents can be added to and removed, etc. All functions are introduced with the db:
prefix, which is linked to the statically declared http://basex.org/modules/db
namespace.
Contents
Conventions
All functions in this module are assigned to the http://basex.org/modules/db
namespace, which is statically bound to the db
prefix.
All errors are assigned to the http://basex.org/errors
namespace, which is statically bound to the bxerr
prefix.
Database Nodes
Many function signatures in this and other modules share $db
as argument to reference an existing database. The argument may either be a string, denoting the name of the addressed database, or a single node from an already opened database. The following errors may be raised by these functions:
BXDB0001
:$db
references an XML node that is not stored in a database, or is no database fragment.BXDB0002
: the addressed database cannot be opened.
Last not but least, the argument may also reference a BaseX-specific database fragment. All XML fragments can be converted to database fragments by applying the transform expression on an XML fragment:
copy $c := element hello { 'world' } modify () return db:text($c, 'world')
General Functions
db:info
Signatures | db:info($db as item()) as element(Database)
|
Summary | Returns meta information on the database specified by the database node $db .
|
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 a database node $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.
|
Examples |
|
db:list-details
Signatures | db:list-details() as element(database)* db:list-details($db as item()) as element(resource)* db:list-details($db as item(), $path as xs:string) as element(resource)*
|
Summary | Returns an element sequence with the names of all databases together with their database path, the number of stored resources and the date of modification.If a database node $db is specified, all documents and raw files of the specified database together with their content-type, the modification date and the resource type are returned.The list of resources can be further restricted by the $path argument.
|
Examples |
|
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 the database node $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 the database node $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. |
Errors | BXDB0009 : the specified id value does not exist in the database.
|
db:open-pre
Signatures | db:open-pre($db as item(), $pre as xs:integer) as node()
|
Summary | Opens the database specified by the database node $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 | BXDB0009 : 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 of the database specified by the database node $db that have $string as string value. If available, the value index is used to speed up evaluation.If $attname is specified, the resulting attribute nodes are filtered by their attribute name.
|
Examples |
|
db:attribute-range
Signatures | db:attribute-range($db as item(), $min as xs:string, $max as xs:string) as text()* db:attribute-range($db as item(), $min as xs:string, $max as xs:string, $attname as xs:string) as attribute()*
|
Summary | Returns all attributes of the database specified by the database node $db , the string values of which are larger than or equal to $min and smaller than or equal to $max . If available, the value index is used to speed up evaluation.
|
Examples |
|
db:fulltext
Signatures | db:fulltext($db as item(), $terms as xs:string) as text()*
|
Summary | Returns all text nodes from the full-text index of the database specified by the database node $db that contain the text specified as $terms .The options used for building the full-text will also be applied to the search terms. As an example, if the index terms have been stemmed, the search string will be stemmed as well. |
Errors | BXDB0004 : the full-text 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 $nodes of the database specified by the database node $db .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 $nodes of the database specified by the database node $db .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 the database node $db and $path .
|
Errors | BXDB0003 : the databse is not persistent (stored on disk).FODC0002 : the addressed resource cannot be retrieved.FODC0007 : the specified path is invalid.
|
Examples |
|
db:text
Signatures | db:text($db as item(), $string as item()) as text()*
|
Summary | Returns all text nodes of the database specified by the database node $db that have $string as their string value. If available, the value index is used to speed up evaluation.
|
Examples |
|
db:text-range
Signatures | db:text-range($db as item(), $min as xs:string, $max as xs:string) as text()*
|
Summary | Returns all text nodes of the database specified by the database node $db that are located in between the $min and $max strings. If available, the value index is used to speed up evaluation.
|
Examples |
|
Updates
All functions in this section are treated as updating: they are not immediately executed, but queued on a pending update list, which is processed after the actual query has been evaluated. The XQuery Update page gives more insight into the relevant concepts.
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 specified by the database node $db and the specified $path .
|
Errors | FODC0002 : $input is a string representing a path, which cannot be read.FOUP0001 : $input is neither string nor 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 specified by the database node $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 specified by the database node $db .If $all is set to true() , the complete database will be rebuilt.
|
Errors | BASX0014 : an error occurs during optimizing the data structures.BASX0015 : the $all flag is set to true() , but the database is an in-memory database.BASX0016 : 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 specified by the database node $db .
|
Errors | BXDB0008 : new document names would 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 specified by the database node $db with the content of $input .
|
Errors | BXDB0006 : $path is not a single document path.FODC0002 : $input is a string representing a path, which cannot be read.FOUP0001 : $input is neither a string nor 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 in the database specified by the database node $db and the location specified by $path .
|
Errors | BXDB0003 : the databse is not persistent (stored on disk).FODC0007 : the specified path is invalid.FOUP0002 : the resource cannot be stored at the specified location.
|
Examples |
|
db:output
Signatures | db:output($data as item()*) as empty-sequence()
|
Summary | This function can be used to both perform updates and return results in a single query. The argument of the function will be evaluated, and the resulting value will be cached and returned after the updates on the pending update list have been processed. The function can only be used together with updating expressions; if the function is called within a transform expression, its results will be discarded. |
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 database specified by the database node $db or the resource specified by {[Mono|$path}} exists. false is returned if a database directory has been addressed.
|
Examples |
|
db:is-raw
Signatures | db:is-raw($db as item(), $path as xs:string) as xs:boolean
|
Summary | Checks if the specified resource in the database specified by the database node $db and the path $path 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 in the database specified by the database node $db and the path $path 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 a resource in the database specified by the database node $db and the path $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 : 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 | BXDB0010 : the specified event is unknown.SEPM0016 : serialization errors occurred while sending the value. |
Errors
Code | Description |
---|---|
BXDB0001
|
A referenced XML node is no database node, i.e. is neither stored in a database nor a database fragment. |
BXDB0002
|
An I/O error occurred while opening a database. |
BXDB0003
|
The addressed database is not persistent (stored on disk). |
BXDB0004
|
The database lacks an index structure required by the called function. |
BXDB0005
|
A query is expected to exclusively return database nodes of a single database. |
BXDB0006
|
A database path addressed with doc() contains more than one document.
|
BXDB0007
|
A database cannot be updated because it is opened by another process. |
BXDB0008
|
Database paths cannot be renamed to empty strings. |
BXDB0009
|
The addressed database id or pre value is out of range. |
BXDB0010
|
The specified event is unknown. |
Changelog
Version 7.2.1
- Added: db:text-range, db:attribute-range, db:output
Version 7.1
- Added: db:list-details, db:content-type
- Updated: db:info, db:system, db:retrieve