Changes

Jump to navigation Jump to search
96 bytes removed ,  18:36, 1 December 2023
m
Text replacement - "</syntaxhighlight>" to "</pre>"
for $i in 1 to 100
return db:get('books' || $i)//book/title
</syntaxhighlightpre>
If the {{Option|DEFAULTDB}} option is turned on, the path argument of the {{Code|fn:doc}} or {{Code|fn:collection}} functions will first be resolved against the globally opened database.
every $c in collection('anyDB')
satisfies doc-available(document-uri($c))
</syntaxhighlightpre>
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:
<pre lang='xquery'>
string(db:get-binary('multimedia', 'sample.avi'))
</syntaxhighlightpre>
==XQuery Values==
let $city-map := db:get-value('indexes', 'cities')
return $city-map?Chile
</syntaxhighlightpre>
=Update Resources=
<pre lang='xquery'>
db:add('documents', '/path/to/xml/resources/')
</syntaxhighlightpre>
Function from other modules, such as the [[File Module]], can be utilized to filter the input. With the following code, all files that contain numbers in the filename are selected, and stored as XML. If an input file contains no well-formed XML, it is stored as binary resource, and the error message is stored as a string value:
db:put-value($db, $err:description, $path || '.error')
}
</syntaxhighlightpre>
The error messages can e.g. be analyzed in a second step:
where ends-with($filename, '.error')
return $filename || ': ' || $errors?($filename)
</syntaxhighlightpre>
=Export Database=
1876462
Query executed in 0.97 ms.
</syntaxhighlightpre>
Additional notes:
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu