Changes

Jump to navigation Jump to search
52 bytes removed ,  18:33, 1 December 2023
m
Text replacement - "</syntaxhighlight>" to "</pre>"
The XQuery expression below serves as an example on how large files can be downloaded and written to a file with constant memory consumption:
<syntaxhighlight pre lang="'xquery"'>
file:write-binary('output.data', fetch:binary('http://files.basex.org/xml/xmark111mb.zip'))
</syntaxhighlightpre>
If lazy items are serialized, they will be streamed as well.
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>lazy:cache(
$items input as item()*, $lazy as xs:boolean ? := false()
) as item()*</pre>
|- valign="top"
| '''Summary'''
|Caches the data of lazy {{Code|$itemsinput}} in a sequenceitems:<br/>
* data of lazy items are retrieved and cached inside the item.
* non-lazy items, or lazy items with cached data, are simply passed through.
| '''Example'''
|In the following example, a file is deleted before its content is returned. To avoid a “file not found” error when serializing the result, the content must be cached:
<syntaxhighlight pre lang="'xquery"'>
let $file := 'data.txt'
let $text := lazy:cache(file:read-text($file))
return (file:delete($file), $text)
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>lazy:is-lazy(
$item as item()
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>lazy:is-cached(
$item as item()
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu