Difference between revisions of "Database Module"
Jump to navigation
Jump to search
m (moved FN:Database to Database Functions: consistent naming) |
(based on docs2wiki.xq) |
||
Line 1: | Line 1: | ||
− | + | This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduced with the <code>db:</code> prefix. | |
− | |||
+ | ==db:system== | ||
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:system</b>() as xs:string | + | |<code><b>db:system</b>() as xs:string</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Lists information on the database system. | + | |Lists information on the database system. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function returns general information on the database system, such as the database path and current database settings.<br /> | + | |This function returns a simple string with general information on the database system, such as the database path and current database settings.<br /> |
|} | |} | ||
− | ==db:list== | + | ==db:list== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:list</b>() as xs:string*</code> | + | |<code><b>db:list</b>() as xs:string*</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Lists all databases. | + | |Lists all databases. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function returns a <code>xs:string</code> sequence with the names of all databases.<br /> | + | |This function returns a <code>xs:string</code> sequence with the names of all databases.<br /> |
|} | |} | ||
− | ==db:open== | + | ==db:open== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:open</b>($name as xs:string) as document-node()</code> | + | |<code><b>db:open</b>($name as xs:string) as document-node()</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | | + | |Retrieves documents from a database. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function opens the documents of the database specified by <code>$name</code>. The name of the database may be extended by a collection path.<br /> | + | |This function opens the documents of the database specified by <code>$name</code>. The name of the database may be extended by a collection path.<br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Examples''' |
− | | The expression <code>db:open("docs")</code> returns all documents from the database named <code>docs</code>.<br />The expression <code>db:open("docs/one")</code> returns all documents from the database named <code>docs</code> in the subpath <code>one</code>.<br /> | + | |The expression <code>db:open("docs")</code> returns all documents from the database named <code>docs</code>.<br />The expression <code>db:open("docs/one")</code> returns all documents from the database named <code>docs</code> in the subpath <code>one</code>.<br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Errors''' |
− | | <b>[BASX0003]</b> is raised if the database is not found.<br /> | + | |<b>[BASX0003]</b> is raised if the database is not found.<br /> |
|} | |} | ||
− | ==db:open-pre== | + | ==db:open-pre== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code> <b>db:open-pre</b>($name as xs:string, $pre as xs:integer) as node()</code> | + | |<code><b>db:open-pre</b>($name as xs:string, $pre as xs:integer) as node()</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns a specific database node. | + | |Returns a specific database node. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function opens the database specified by <code>$name</code> and returns the node with the <i>pre</i> value specified by <code>$pre</code>.<br /> | + | |This function opens the database specified by <code>$name</code> and returns the node with the <i>pre</i> value specified by <code>$pre</code>.<br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Examples''' |
− | | The expression <code>db:open-pre("docs", 0)</code> returns the first database node from the database named <code>docs</code>.<br /> | + | |The expression <code>db:open-pre("docs", 0)</code> returns the first database node from the database named <code>docs</code>.<br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Errors''' |
− | | <b>[BASX0004]</b> is raised if the specified <code>$pre</code> value does not exist in the database.<br /> | + | |<b>[BASX0004]</b> is raised if the specified <code>$pre</code> value does not exist in the database.<br /> |
|} | |} | ||
− | ==db:open-id== | + | ==db:open-id== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:open-id</b>($name as xs:string, $id as xs:integer) as node()</code> | + | |<code><b>db:open-id</b>($name as xs:string, $id as xs:integer) as node()</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns a specific database node. | + | |Returns a specific database node. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function opens the database specified by <code>$name</code> and returns the node with the <i>id</i> value specified by <code>$id</code>.<br />In contrast to the <i>pre</i> value, the <i>id</i> will remain valid after update operations.<br /> | + | |This function opens the database specified by <code>$name</code> and returns the node with the <i>id</i> value specified by <code>$id</code>.<br />In contrast to the <i>pre</i> value, the <i>id</i> will remain valid after update operations.<br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Errors''' |
− | | <b>[BASX0004]</b> is raised if the specified <code>$id</code> does not exist in the database.<br /> | + | |<b>[BASX0004]</b> is raised if the specified <code>$id</code> does not exist in the database.<br /> |
|} | |} | ||
− | ==db:text | + | ==db:text== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:text | + | |<code><b>db:text</b>($string as item()) as text()*</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns results from a text | + | |Returns results from a text index request. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function accesses the text index and returns all text nodes that have <code>$string</code> as string value.<br /> | + | |This function accesses the text index and returns all text nodes that have <code>$string</code> as string value.<br /> |
|- | |- | ||
− | | < | + | | valign='top' | '''Examples''' |
− | |<b>[BASX0001]</b> is raised if the index is not available.<br /> <b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | + | |The expression <code>db:text("QUERY")</code> returns all text nodes of the currently opened database that match the string <code>QUERY</code>.<br />The expression <code>db:open("DB")/db:text("QUERY")/..</code> returns the parents of all text nodes of the database <code>DB</code> that match the string <code>QUERY</code>.<br /> |
+ | |- | ||
+ | | valign='top' | '''Errors''' | ||
+ | |<b>[BASX0001]</b> is raised if the index is not available.<br /><b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | ||
|} | |} | ||
− | ==db:attribute | + | ==db:attribute== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:attribute | + | |<code><b>db:attribute</b>($string as item()) as attribute()*</code><br /><code><b>db:attribute</b>($string as item(), $name as xs:string) as attribute()*</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns results from a attribute | + | |Returns results from a attribute index request. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function accesses the attribute index and returns all attribute nodes that have <code>$string</code> as string value.<br />If <code>$name</code> is specified, the resulting attribute nodes are filtered by their attribute name.<br /> | + | |This function accesses the attribute index and returns all attribute nodes that have <code>$string</code> as string value.<br />If <code>$name</code> is specified, the resulting attribute nodes are filtered by their attribute name.<br /> |
|- | |- | ||
− | | < | + | | valign='top' | '''Examples''' |
− | |<b>[BASX0001]</b> is raised if the index is not available.<br /><b>[BASX0002]</b> is raised if the context item does not represent a database node. | + | |The expression <code>db:open("DB")/db:attribute("QUERY", "id")/..</code> returns the parents of all attribute nodes of the database <code>DB</code> that have <code>QUERY</code> as string value.<br /> |
+ | |- | ||
+ | | valign='top' | '''Errors''' | ||
+ | |<b>[BASX0001]</b> is raised if the index is not available.<br /><b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | ||
|} | |} | ||
− | ==db:fulltext | + | ==db:fulltext== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | |<code><b>db:fulltext | + | |<code><b>db:fulltext</b>($text as xs:string) as text()</code><br /> |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns results from a full-text | + | |Returns results from a full-text index request. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function accesses the full-text index and returns all text nodes that contain <code>$text</code>.<br /> | + | |This function accesses the full-text index and returns all text nodes that contain the string <code>$text</code>. The index full-text options are used for searching, i.e., if the index terms were stemmed, the search string will be stemmed as well.<br /> |
|- | |- | ||
− | | < | + | | valign='top' | '''Examples''' |
− | |<b>[BASX0001]</b> is raised if the index is not available.<br /> <b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | + | |The expression <code>db:fulltext("QUERY")</code> returns all text nodes of the currently opened database that contain the string <code>QUERY</code>.<br /> |
+ | |- | ||
+ | | valign='top' | '''Errors''' | ||
+ | |<b>[BASX0001]</b> is raised if the index is not available.<br /><b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | ||
|} | |} | ||
− | ==db:info== | + | ==db:info== |
{| | {| | ||
|- | |- | ||
− | | width= | + | | valign='top' width='90' | '''Signatures''' |
− | + | |<code><b>db:info</b>() as xs:string</code><br /><code><b>db:info</b>($type as xs:string) as xs:string</code><br /> | |
|- | |- | ||
− | | | + | | valign='top' | '''Summary''' |
− | | Returns database information. | + | |Returns database information. |
|- | |- | ||
− | | | + | | valign='top' | '''Rules''' |
− | | This function returns information on the database that is referenced by the current context item.<br /> | + | |This function returns information on the database that is referenced by the current context item.<br />If <code>$type</code> is specified, the funnction returns information on a database index. It must be one of the values <code>TEXT</code>, <code>ATTRIBUTE</code>, <code>FULLTEXT</code>, <code>PATH</code>, <code>TAG</code>, or <code>ATTNAME</code>.<br /> |
|- | |- | ||
− | | <b> | + | | valign='top' | '''Errors''' |
− | + | |<b>[BASX0001]</b> is raised if the specified index is not available.<br /><b>[BASX0002]</b> is raised if the context item does not represent a database node.<br /> | |
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:XQuery]] | [[Category:XQuery]] |
Revision as of 20:59, 13 December 2010
This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduced with the db:
prefix.
Contents
db:system
Signatures | db:system() as xs:string |
Summary | Lists information on the database system. |
Rules | This function returns a simple string with general information on the database system, such as the database path and current database settings. |
db:list
Signatures | db:list() as xs:string* |
Summary | Lists all databases. |
Rules | This function returns a xs:string sequence with the names of all databases. |
db:open
Signatures | db:open($name as xs:string) as document-node() |
Summary | Retrieves documents from a database. |
Rules | This function opens the documents of the database specified by $name . The name of the database may be extended by a collection path. |
Examples | The expression db:open("docs") returns all documents from the database named docs .The expression db:open("docs/one") returns all documents from the database named docs in the subpath one . |
Errors | [BASX0003] is raised if the database is not found. |
db:open-pre
Signatures | db:open-pre($name as xs:string, $pre as xs:integer) as node() |
Summary | Returns a specific database node. |
Rules | This function opens the database specified by $name and returns the node with the pre value specified by $pre . |
Examples | The expression db:open-pre("docs", 0) returns the first database node from the database named docs . |
Errors | [BASX0004] is raised if the specified $pre value does not exist in the database. |
db:open-id
Signatures | db:open-id($name as xs:string, $id as xs:integer) as node() |
Summary | Returns a specific database node. |
Rules | This function opens the database specified by $name and returns the node with the id value specified by $id .In contrast to the pre value, the id will remain valid after update operations. |
Errors | [BASX0004] is raised if the specified $id does not exist in the database. |
db:text
Signatures | db:text($string as item()) as text()* |
Summary | Returns results from a text index request. |
Rules | This function accesses the text index and returns all text nodes that have $string as string value. |
Examples | The expression db:text("QUERY") returns all text nodes of the currently opened database that match the string QUERY .The expression db:open("DB")/db:text("QUERY")/.. returns the parents of all text nodes of the database DB that match the string QUERY . |
Errors | [BASX0001] is raised if the index is not available. [BASX0002] is raised if the context item does not represent a database node. |
db:attribute
Signatures | db:attribute($string as item()) as attribute()* db:attribute($string as item(), $name as xs:string) as attribute()* |
Summary | Returns results from a attribute index request. |
Rules | This function accesses the attribute index and returns all attribute nodes that have $string as string value.If $name is specified, the resulting attribute nodes are filtered by their attribute name. |
Examples | The expression db:open("DB")/db:attribute("QUERY", "id")/.. returns the parents of all attribute nodes of the database DB that have QUERY as string value. |
Errors | [BASX0001] is raised if the index is not available. [BASX0002] is raised if the context item does not represent a database node. |
db:fulltext
Signatures | db:fulltext($text as xs:string) as text() |
Summary | Returns results from a full-text index request. |
Rules | This function accesses the full-text index and returns all text nodes that contain the string $text . The index full-text options are used for searching, i.e., if the index terms were stemmed, the search string will be stemmed as well. |
Examples | The expression db:fulltext("QUERY") returns all text nodes of the currently opened database that contain the string QUERY . |
Errors | [BASX0001] is raised if the index is not available. [BASX0002] is raised if the context item does not represent a database node. |
db:info
Signatures | db:info() as xs:string db:info($type as xs:string) as xs:string |
Summary | Returns database information. |
Rules | This function returns information on the database that is referenced by the current context item. If $type is specified, the funnction returns information on a database index. It must be one of the values TEXT , ATTRIBUTE , FULLTEXT , PATH , TAG , or ATTNAME . |
Errors | [BASX0001] is raised if the specified index is not available. [BASX0002] is raised if the context item does not represent a database node. |