Changes

Jump to navigation Jump to search
649 bytes removed ,  13:52, 20 May 2013
no edit summary
==Database Nodes==
Many function signatures in this and other modules share {{CodeMark|$dbWith Version 7.7}} , the database functions no longer accept database nodes as argument to reference an existing database. The argument may either be a stringInstead, denoting the name of the addressed database, or a single node from an already opened databasemust now be specified. The following errors This argument is consistently labeled as {{Code|$db}}. {{Error|BXDB0002|#Errors}} may be raised by these functions:if the addressed database cannot be opened.
* {{Error|BXDB0001|#Errors}} {{Code|$db}} references an Database nodes are XML node that is not nodes which are either stored in a persistent database, or is no database fragment.* {{Error|BXDB0002|#Errors}} the addressed database cannot be opened. Last not but least, the argument may also reference part of a BaseXso-specific called ''database fragment''. All XML fragments can be converted to database fragments by e. g. applying the [[XQuery_Update#transform|transform]] expression on an XML fragment:
<pre class="brush:xquery">
copy $c := element hello { 'world' }
modify ()
return db:text($c, 'world')
</pre>
|-
| width='90' | '''Signatures'''
|{{Func|db:info|$db as item()xs:string|element(database)}}
|-
| '''Summary'''
|Returns meta information on the database specified by the [[#Database Nodes|database node]] {{Code|$db}}.
|}
|-
| width='90' | '''Signatures'''
|{{Func|db:list||xs:string*}}<br/>{{Func|db:list|$db as item()xs:string|xs:string*}}<br/>{{Func|db:list|$db as item()xs:string, $path as xs:string|xs:string*}}
|-
| '''Summary'''
|Returns a string sequence with the names of all databases.<br/>If a [[#Database Nodes|database node]] {{Code|$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 {{Code|$path}} argument.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:list-details||element(database)*}}<br/>{{Func|db:list-details|$db as item()xs:string|element(resource)*}}<br/>{{Func|db:list-details|$db as item()xs:string, $path as xs:string|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.<br/>If a [[#Database Nodes|database node]] {{Code|$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.<br/>The list of resources can be further restricted by the {{Code|$path}} argument.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:open|$db as item()xs:string|document-node()*}}<br />{{Func|db:open|$db as item()xs:string, $path as xs:string|document-node()*}}
|-
| '''Summary'''
|Returns a sequence with all document nodes contained in the database specified by the [[#Database Nodes|database node]] {{Code|$db}}.<br/>The document nodes to be returned can be restricted by the {{Code|$path}} argument.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:open-id|$db as item()xs:string, $id as xs:integer|node()}}
|-
| '''Summary'''
|Opens the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and returns the node with the specified {{Code|$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.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:open-pre|$db as item()xs:string, $pre as xs:integer|node()}}
|-
| '''Summary'''
|Opens the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and returns the node with the specified {{Code|$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.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:backups||element(backup)*}}<br/>{{Func|db:backups|$db as item()xs:string|element(backup)*}}
|-
| '''Summary'''
|Returns an element sequence containing all available database backups.<br/>If a [[#Database Nodes|database node]] {{Code|$db}} is specified, the sequence will be restricted to the backups matching this database.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:attribute|$db as item()xs:string, $string as item()|attribute()*}}<br/>{{Func|db:attribute|$db as item()xs:string, $string as item(), $attname as xs:string|attribute()*}}
|-
| '''Summary'''
|Returns all attribute nodes of the database specified by the [[#Database Nodes|database node]] {{Code|$db}} that have {{Code|$string}} as string value. If available, the value index is used to speed up evaluation.<br />If {{Code|$attname}} is specified, the resulting attribute nodes are filtered by their attribute name.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:attribute-range|$db as item()xs:string, $min as xs:string, $max as xs:string|attribute()*}}<br/>{{Func|db:attribute-range|$db as item()xs:string, $min as xs:string, $max as xs:string, $attname as xs:string|attribute()*}}
|-
| '''Summary'''
|Returns all attributes of the database specified by the [[#Database Nodes|database node]] {{Code|$db}}, the string values of which are larger than or equal to {{Code|$min}} and smaller than or equal to {{Code|$max}}. If available, the value index is used to speed up evaluation.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:fulltext|$db as item()xs:string, $terms as xs:string|text()*}}
|-
| '''Summary'''
|Returns all text nodes from the full-text index of the database specified by the [[#Database Nodes|database node]] {{Code|$db}} that contain the text specified as {{Code|$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.
|-
| '''Errors'''
|-
| '''Errors'''
|{{Error|BXDB0001|#Errors}} {{Code|$nodes}} contains a node which is not stored in a [[#Database Nodes|database node]].
|}
|-
| '''Errors'''
|{{Error|BXDB0001|#Errors}} {{Code|$nodes}} contains a node which is not stored in a [[#Database Nodes|database node]].
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:retrieve|$db as item()xs:string, $path as xs:string|xs:base64Binary}}
|-
| '''Summary'''
|Returns a binary database resource addressed by the [[#Database Nodes|database node]] {{Code|$db}} and {{Code|$path}} as [[Streaming Module|streamable]] {{Code|xs:base64Binary}}.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:text|$db as item()xs:string, $string as item()|text()*}}
|-
| '''Summary'''
|Returns all text nodes of the database specified by the [[#Database Nodes|database node]] {{Code|$db}} that have {{Code|$string}} as their string value. If available, the value index is used to speed up evaluation.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:text-range|$db as item()xs:string, $min as xs:string, $max as xs:string|text()*}}
|-
| '''Summary'''
|Returns all text nodes of the database specified by the [[#Database Nodes|database node]] {{Code|$db}} that are located in between the {{Code|$min}} and {{Code|$max}} strings. If available, the value index is used to speed up evaluation.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:drop|$db as item()xs:string|empty-sequence()}}
|-
| '''Summary'''
|Drops the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and all connected resources.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:add|$db as item()xs:string, $input as item()|empty-sequence()}}<br/>{{Func|db:add|$db as item()xs:string, $input as item(), $path as xs:string|empty-sequence()}}
|-
| '''Summary'''
|Adds documents specified by {{Code|$input}} to the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and the specified {{Code|$path}}.<br/>{{Code|$input}} may be a string or a node different than attribute. If the {{Code|$input}} source is not a file or a folder, {{Code|$path}} must be specified.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:delete|$db as item()xs:string, $path as xs:string|empty-sequence()}}
|-
| '''Summary'''
|Deletes document(s), specified by {{Code|$path}}, from the database specified by the [[#Database Nodes|database node]] {{Code|$db}}.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:optimize|$db as item()xs:string|empty-sequence()}}<br/>{{Func|db:optimize|$db as item()xs:string, $all as xs:boolean|empty-sequence()}}
|-
| '''Summary'''
|Optimizes the meta data and indexes of the database specified by the [[#Database Nodes|database node]] {{Code|$db}}.<br/>If {{Code|$all}} is set to {{Code|true()}}, the complete database will be rebuilt.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:rename|$db as item()xs:string, $path as xs:string, $newpath as xs:string|empty-sequence()}}
|-
| '''Summary'''
|Renames document(s), specified by {{Code|$path}} to {{Code|$newpath}} in the database specified by the [[#Database Nodes|database node]] {{Code|$db}}.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:replace|$db as item()xs:string, $path as xs:string, $input as item()|empty-sequence()}}
|-
| '''Summary'''
|Replaces a document, specified by {{Code|$path}}, in the database specified by the [[#Database Nodes|database node]] {{Code|$db}} with the content of {{Code|$input}}, or adds it as a new document.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:store|$db as item()xs:string, $path as xs:string, $input as item()|empty-sequence()}}
|-
| '''Summary'''
|Stores a binary resource specified by {{Code|$input}} in the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and the location specified by {{Code|$path}}.
|-
| '''Errors'''
|-
| width='90' | '''Signatures'''
|{{Func|db:flush|$db as item()xs:string|empty-sequence()}}
|-
| '''Summary'''
|Explicitly flushes the buffers of the database specified by the [[#Database Nodes|database node]] {{Code|$db}}. This command is only useful if [[Options#AUTOFLUSH|AUTOFLUSH]] has been set to {{Code|false}}.
|}
|-
| width='90' | '''Signatures'''
|{{Func|db:exists|$db as item()xs:string|xs:boolean}}<br/>{{Func|db:exists|$db as item()xs:string, $path as xs:string|xs:boolean}}
|-
| '''Summary'''
|Checks if the database specified by the [[#Database Nodes|database node]] {{Code|$db}} or the resource specified by {{Code|$path}} exists. {{Code|false}} is returned if a database directory has been addressed.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:is-raw|$db as item()xs:string, $path as xs:string|xs:boolean}}
|-
| '''Summary'''
|Checks if the specified resource in the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and the path {{Code|$path}} exists, and if it is a raw file.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:is-xml|$db as item()xs:string, $path as xs:string|xs:boolean}}
|-
| '''Summary'''
|Checks if the specified resource in the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and the path {{Code|$path}} exists, and if it is an XML document.
|-
| '''Examples'''
|-
| width='90' | '''Signatures'''
|{{Func|db:content-type|$db as item()xs:string, $path as xs:string|xs:string}}
|-
| '''Summary'''
|Retrieves the content type of a resource in the database specified by the [[#Database Nodes|database node]] {{Code|$db}} and the path {{Code|$path}}.<br/>The file extension is used to recognize the content-type of a resource stored in the database. Content-type {{Code|application/xml}} will be returned for any XML document stored in the database, regardless of its file name extension.
|-
| '''Errors'''
|-
|{{Code|BXDB0001}}
|A referenced XML node is no [[#Database Nodes|database node]], i.e. is neither stored in a database nor a database fragment.
|-
|{{Code|BXDB0002}}
=Changelog=
 
;Version 7.7
 
* Updated: instead of [[#Database Nodes|Database Nodes]], the name of a database must now be specified.
;Version 7.6
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu