Changes

Jump to navigation Jump to search
25 bytes removed ,  18:34, 7 December 2013
|<code>[http://www.xqueryfunctions.com/xq/fn_doc.html fn:doc]</code>
|{{Code|doc("db/path/to/doc.xml")}}
|Returns the document at the location {{Code|path/to/docs}} in the database {{Code|db}}.<br/>An error is raised if the specified addresses does not address exactly yields zero or more than one document.
|}
If the [[Options#DEFAULTDB|DEFAULTDB]] option is turned on, the path argument of the {{Code|fn:doc}} or {{Code|fn:collection}} function will first be matched resolved against the globally opened database.
Two more functions are available for retrieving information on database nodes:
!Description
|-
|<code>[[Database Module#db:name|db:name()]]</code>
|{{Code|db:name($node)}}
|Returns the name of the database in which the specified {{Code|$node}} is stored.
|-
|<code>[[Database Module#db:path|db:path()]]</code>
|{{Code|db:path($node)}}
|Returns the path of the database document in which the specified {{Code|$node}} is stored.
|}
The {{Code|fn:document-uri()}} and {{Code|fn:base-uri()}} functions return URIs that can also be reused as arguments for the {{Code|fn:doc()}} and {{Code|fn:collection()}} functions. As a result, the following example query always returns {{Code|true}}:
<pre class="brush:xquery">
</pre>
If the argument of {{Code|fn:doc()}} or {{Code|fn:collection()}} does not start with a valid database name, or if the addressed database does not exist, the string is interpreted as URI reference, and the documents found at this location will be returned. Examples:
* {{Code|doc("http://web.de")}}: retrieves the addressed URI and returns it as a main-memory document node.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu