Lazy Module

This XQuery Module contains functions for handling lazy items.

In contrast to standard XQuery items, a lazy item contains a reference to the actual data, and the data itself will only be retrieved if it is requested. Hence, possible errors will be postponed, and no memory will be occupied by a lazy item as long as its content has not been requested yet.

The following BaseX functions return lazy items:


 * Lazy Base64 binaries:


 * Lazy strings:

Some functions are capable of consuming the contents of lazy items in a streamable fashion: data will not be cached, but instead passed on to another target (file, the calling expression, etc.). The following streaming functions are currently available:


 * Archive Module (most functions)
 * Conversion Module: ,
 * Database Module:
 * File Module:,   (if no encoding is specified)
 * Hashing Module (all functions)

The XQuery expression below serves as an example on how large files can be downloaded and written to a file with constant memory consumption:

 file:write-binary('output.data', fetch:binary('http://files.basex.org/xml/xmark111mb.zip'))

If lazy items are serialized, they will be streamed as well.

=Conventions=

All functions and errors in this module are assigned to the  namespace, which is statically bound to the lazy prefix.

=Functions=

lazy:is-cached
=Changelog=


 * Version 9.1


 * Updated: lazy:cache: $lazy argument added; support for sequences.


 * Version 9.0


 * Updated: Renamed from Streaming Module to Lazy Module.
 * Added: lazy:is-cached


 * Version 8.0


 * Updated: stream:materialize extended to sequences.

This module was introduced with Version 7.7.