Changes

Jump to navigation Jump to search
885 bytes removed ,  00:42, 26 May 2012
m
Text replace - "| valign='top' | " to "| "
|{{Mono|'''db:info'''($db as item()) as element(Database)}}
|-
| valign='top' | '''Summary'''
|Returns meta information on the database specified by <code>[[#Database Nodes|$db]]</code>.
|}
|{{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'''
|Returns an {{Mono|xs:string}} sequence with the names of all databases.<br/>If <code>[[#Database Nodes|$db]]</code> 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.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:list("docs")}} returns the names of all documents from the database named {{Mono|docs}}.
|{{Mono|'''db:list-details'''() as element(database)*}}<br/>{{Mono|'''db:list-details'''($db as item()) as element(resource)*}}<br/>{{Mono|'''db:list-details'''($db as item(), $path as xs:string) as element(resource)*}}
|-
| valign='top' | '''Summary'''
|Returns an {{Mono|element}} sequence with the names of all databases together with their database path, the number of stored resources and the date of modification.<br/>If <code>[[#Database Nodes|$db]]</code> 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.<br/>The list of resources can be further restricted by the {{Mono|$path}} argument.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:list-details("docs")}} returns the names plus additional data of all documents from the database named {{Mono|docs}}.
|{{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'''
|Returns a sequence with all document nodes contained in the database specified by <code>[[#Database Nodes|$db]]</code>.<br/>The document nodes to be returned can be restricted by the {{Mono|$path}} argument.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:open("docs")}} returns all documents from the database named {{Mono|docs}}.
|{{Mono|'''db:open-id'''($db as item(), $id as xs:integer) as node()}}
|-
| valign='top' | '''Summary'''
|Opens the database specified by <code>[[#Database Nodes|$db]]</code> 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.
|}
|{{Mono|'''db:open-pre'''($db as item(), $pre as xs:integer) as node()}}
|-
| valign='top' | '''Summary'''
|Opens the database specified by <code>[[#Database Nodes|$db]]</code> 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'''
|'''[[XQuery Errors#BaseX Errors|BASX0004]]''' is raised if the specified {{Mono|$pre}} value does not exist in the database.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:open-pre("docs", 0)}} returns the first database node from the database named {{Mono|docs}}.
|{{Mono|'''db:system'''() as element(system)}}
|-
| valign='top' | '''Summary'''
|Returns information on the database system, such as the database path and current database settings.
|}
|{{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'''
|Returns all attribute nodes of the database specified by <code>[[#Database Nodes|$db]]</code> that have {{Mono|$string}} as string value. If available, the value index is used to speed up evaluation.<br />If {{Mono|$attname}} is specified, the resulting attribute nodes are filtered by their attribute name.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:attribute("DB", "QUERY", "id")/..}} returns the parents of all {{Mono|id}} attribute nodes of the database {{Mono|DB}} that have {{Mono|QUERY}} as string value.
|{{Mono|'''db:attribute-range'''($db as item(), $min as xs:string, $max as xs:string) as text()*}}<br/>{{Mono|'''db:attribute-range'''($db as item(), $min as xs:string, $max as xs:string, $attname as xs:string) as attribute()*}}
|-
| valign='top' | '''Summary'''
|Returns all attributes of the database specified by <code>[[#Database Nodes|$db]]</code>, the string values of which are larger than or equal to {{Mono|$min}} and smaller than or equal to {{Mono|$max}}. If available, the value index is used to speed up evaluation.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:attribute-range("DB", "id456", "id473", 'id')}} returns all {{Mono|@id}} attributes of the database {{Mono|DB}} that have a string value in between {{Mono|id456}} and {{Mono|id473}}.
|{{Mono|'''db:fulltext'''($db as item(), $terms as xs:string) as text()*}}
|-
| valign='top' | '''Summary'''
|Returns all text nodes from the full-text index of the database specified by <code>[[#Database Nodes|$db]]</code> that contain the text specified as {{Mono|$terms}}.<br/>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.
|-
| valign='top' | '''Errors'''
|'''[[#Errors|BXDB0004]]''' is raised if the full-text index is not available.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:fulltext("DB", "QUERY")}} returns all text nodes of the database {{Mono|DB}} that contain the string {{Mono|QUERY}}.
|{{Mono|'''db:node-id'''($nodes as node()*) as xs:integer*}}
|-
| valign='top' | '''Summary'''
|Returns the ''id'' values of all {{Mono|$nodes}} of the database specified by <code>[[#Database Nodes|$db]]</code>.<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.
|}
|{{Mono|'''db:node-pre'''($nodes as node()*) as xs:integer*}}
|-
| valign='top' | '''Summary'''
|Returns the ''pre'' values of all {{Mono|$nodes}} of the database specified by <code>[[#Database Nodes|$db]]</code>.<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'''
|
* {{Mono|db:node-pre(doc("input"))}} returns {{Mono|0}} if the database {{Mono|input}} contains a single document.
|{{Mono|'''db:retrieve'''($db as item(), $path as xs:string) as xs:base64Binary}}
|-
| valign='top' | '''Summary'''
|Returns a binary database resource addressed by <code>[[#Database Nodes|$db]]</code> and {{Mono|$path}}.
|-
| valign='top' | '''Errors'''
|'''[[#Errors|BXDB0003]]''' is raised if the databse is not ''persistent'' (stored on disk).<br/>'''[[XQuery Errors#Functions Errors|FODC0002]]''' is raised if the addressed resource cannot be retrieved.<br/>'''[[XQuery Errors#Functions Errors|FODC0007]]''' is raised if the specified path is invalid.
|-
| valign='top' | '''Examples'''
|
* {{Mono|declare option output:method 'raw';<br/>db:retrieve("DB", "music/01.mp3")}} returns the specified audio file as raw data.
|{{Mono|'''db:text'''($db as item(), $string as item()) as text()*}}
|-
| valign='top' | '''Summary'''
|Returns all text nodes of the database specified by <code>[[#Database Nodes|$db]]</code> that have {{Mono|$string}} as their string value. If available, the value index is used to speed up evaluation.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:text("DB", "QUERY")/..}} returns the parents of all text nodes of the database {{Mono|DB}} that match the string {{Mono|QUERY}}.
|{{Mono|'''db:text-range'''($db as item(), $min as xs:string, $max as xs:string) as text()*}}
|-
| valign='top' | '''Summary'''
|Returns all text nodes of the database specified by <code>[[#Database Nodes|$db]]</code> that are located in between the {{Mono|$min}} and {{Mono|$max}} strings. If available, the value index is used to speed up evaluation.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:text-range("DB", "2000", "2001")}} returns all text nodes of the database {{Mono|DB}} that are found in between {{Mono|2000}} and {{Mono|2001}}.
|{{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'''
|Adds documents specified by {{Mono|$input}} to the database <code>[[#Database Nodes|$db]]</code> and the specified {{Mono|$path}}.
|-
| 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 neither string nor a document node.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:add("DB", "/home/dir/doc.xml")}} adds the file {{Mono|/home/dir/doc.xml}} to the database {{Mono|DB}}.
|{{Mono|'''db:delete'''($db as item(), $path as xs:string) as empty-sequence()}}
|-
| valign='top' | '''Summary'''
|Deletes document(s), specified by {{Mono|$path}}, from the database <code>[[#Database Nodes|$db]]</code>.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:delete("DB", "docs/dir/doc.xml")}} deletes the document {{Mono|docs/dir/doc.xml}} in the database {{Mono|DB}}.
|{{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'''
|Optimizes the meta data and indexes of the database <code>[[#Database Nodes|$db]]</code>.<br/>If {{Mono|$all}} is set to {{Mono|true()}}, the complete database will be rebuilt.
|-
| 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'''
|
* {{Mono|db:optimize("DB")}} optimizes the database structures of the database {{Mono|DB}}.
|{{Mono|'''db:rename'''($db as item(), $path as xs:string, $newpath as xs:string) as empty-sequence()}}
|-
| valign='top' | '''Summary'''
|Renames document(s), specified by {{Mono|$path}} to {{Mono|$newpath}} in the database <code>[[#Database Nodes|$db]]</code>.
|-
| valign='top' | '''Errors'''
|'''[[XQuery Errors#BaseX Errors|BASX0013]]''' is raised if new document name(s) will be empty.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:rename("DB", "docs/dir/doc.xml", "docs/dir/newdoc.xml")}} renames the document {{Mono|docs/dir/doc.xml}} to {{Mono|docs/dir/newdoc.xml}} in the database {{Mono|DB}}.
|{{Mono|'''db:replace'''($db as item(), $path as xs:string, $input as item()) as empty-sequence()}}
|-
| valign='top' | '''Summary'''
|Replaces a document, specified by {{Mono|$path}}, in the database <code>[[#Database Nodes|$db]]</code> with the content of {{Mono|$input}}.
|-
| valign='top' | '''Errors'''
|'''[[#Errors|BXDB0006]]''' 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 neither a string nor a document node.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:replace("DB", "docs/dir/doc.xml", "/home/dir/doc.xml")}} replaces the content of the document {{Mono|docs/dir/doc.xml}} in the database {{Mono|DB}} with the content of the file {{Mono|/home/dir/doc.xml}}.
|{{Mono|'''db:store'''($db as item(), $path as xs:string, $data as item()) as empty-sequence()}}
|-
| valign='top' | '''Summary'''
|Stores a binary resource specified by {{Mono|$data}} in the database specified by <code>[[#Database Nodes|$db]]</code> and the location specified by {{Mono|$path}}.
|-
| valign='top' | '''Errors'''
|'''[[#Errors|BXDB0003]]''' is raised if the databse is not ''persistent'' (stored on disk).<br/>'''[[XQuery Errors#Functions Errors|FODC0007]]''' is raised if the specified path is invalid.<br/>'''[[XQuery Errors#Update Errors|FOUP0002]]''' is raised if the resource cannot be stored at the specified location.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:store("DB", "video/sample.mov", file:read-binary('video.mov'))}} stores the addressed video file at the specified location.
|{{Mono|'''db:output'''($data as item()*) as empty-sequence()}}
|-
| valign='top' | '''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.<br/>The function can only be used together with [[XQuery Update#Updating Expressions|updating expressions]]; if the function is called within a transform expression, its results will be discarded.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:output("Prices have been deleted."), delete node //price}} deletes all {{Mono|price}} elements in a database and returns an info message.
|{{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'''
|Checks if the database specified by <code>[[#Database Nodes|$db]]</code> or the resource specified by {[Mono|$path}} exists. {{Mono|false}} is returned if a database directory has been addressed.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:exists("DB")}} returns {{Mono|true}} if the database {{Mono|DB}} exists.
|{{Mono|'''db:is-raw'''($db as item(), $path as xs:string) as xs:boolean}}
|-
| valign='top' | '''Summary'''
|Checks if the specified resource in the database <code>[[#Database Nodes|$db]]</code> and the path {{Mono|$path}} exists, and if it is a raw file.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:is-raw("DB", "music/01.mp3")}} returns {{Mono|true}}.
|{{Mono|'''db:is-xml'''($db as item(), $path as xs:string) as xs:boolean}}
|-
| valign='top' | '''Summary'''
|Checks if the specified resource in the database <code>[[#Database Nodes|$db]]</code> and the path {{Mono|$path}} exists, and if it is an XML document.
|-
| valign='top' | '''Examples'''
|
* {{Mono|db:is-xml("DB", "dir/doc.xml")}} returns {{Mono|true}}.
|{{Mono|'''db:content-type'''($db as item(), $path as xs:string) as xs:string}}
|-
| valign='top' | '''Summary'''
|Retrieves the content type of a resource in the database <code>[[#Database Nodes|$db]]</code> and the path {{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'''
|
* {{Mono|db:content-type("DB", "docs/doc01.pdf")}} returns {{Mono|application/pdf}}.
|{{Mono|'''db:event'''($name as xs:string, $query as item()) as empty-sequence()}}
|-
| 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' | '''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/>
|}
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu