http://zorba.io/modules/store/static/collections/ddl

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace cddl = "http://zorba.io/modules/store/static/collections/ddl";
This modules defines a set of functions for managing collections that are declared in the prolog of a module. For example, it provides functions to create, delete, or introspect collections.

This module is part of Zorba's XQuery Data Definition Facility. All the collections managed by this module have to be pre-declared in the prolog of a module. Please refer to the general documentation for more information and examples.

Module code

Here is the actual XQuery module code.

See also

Authors

Nicolae Brinza, Matthias Brantner, David Graf, Till Westmann, Markos Zaharioudakis

Version Declaration

xquery version "3.0" encoding "utf-8";

Namespaces

cddlhttp://zorba.io/modules/store/static/collections/ddl
verhttp://zorba.io/options/versioning
zerrhttp://zorba.io/errors

Function Summary

available-collections() as xs:QName* external

Gets the QNames of the collections that have been statically declared and are available, if any.

create($name as xs:QName) external

Creates a collection.

create($name as xs:QName, $content as item()*) external

Creates a collection and adds the given sequence as content to the new collection.

declared-collections() as xs:QName* external

Gets the collections that have been declared in the prolog of the static context.

delete($name as xs:QName) external

Deletes a collection.

is-available-collection($name as xs:QName) as xs:boolean external

Gets whether a collection is statically declared and available.

is-declared-collection($name as xs:QName) as xs:boolean external

Gers whether a collection was declared in the prolog of the static context.

Functions

available-collections#0

declare function cddl:available-collections() as xs:QName* external

Gets the QNames of the collections that have been statically declared and are available, if any.

Returns

  • xs:QName*

    A sequence comprising one QName for each statically declared and available collection or an emtpy sequence if no such collections are available.

create#1

declare updating function cddl:create(
    $name as xs:QName
) as item()* external

Creates a collection.

Parameters

  • $name

    The of the collection to create.

Errors

  • zerr:ZDDY0001

    if $name is not equal to any of the declared collections in the static context.

  • zerr:ZDDY0002

    if a collection with $name already exists.

create#2

declare updating function cddl:create(
    $name as xs:QName,
    $content as item()*
) as item()* external

Creates a collection and adds the given sequence as content to the new collection.

Parameters

  • $name

    The name of the collection to create.

  • $content

    The sequences of items (nodes or JSON items) to be added to the new collection.

Errors

  • zerr:ZDDY0001

    if $name is not equal to any of the declared collections in the static context.

  • zerr:ZDDY0002

    if a collection with $name already exists.

  • zerr:ZDTY0001

    if $content does not match the expected type declared by the collection according to the rules for SequenceType Matching.

declared-collections#0

declare function cddl:declared-collections() as xs:QName* external

Gets the collections that have been declared in the prolog of the static context.

Returns

  • xs:QName*

    A sequence of QNames, one for each collection created in the static context, or an emtpy sequence.

delete#1

declare updating function cddl:delete(
    $name as xs:QName
) as item()* external

Deletes a collection.

Parameters

  • $name

    The collection to delete.

Errors

  • zerr:ZDDY0001

    if $name is not equal to any of the declared collections in the static context.

  • zerr:ZDDY0003

    if the collection identified by $name is not available.

  • zerr:ZDDY0013

    if the domain or key expression of any of the available indexes access the collection having $name.

  • zerr:ZDDY0015

    if any of the in-scope variables references an item that belongs to the collection having $name

is-available-collection#1

declare function cddl:is-available-collection(
    $name as xs:QName
) as xs:boolean external

Gets whether a collection is statically declared and available.

Parameters

  • $name

    The name of the collection to check.

Returns

  • xs:boolean

    true if the collection was statically declared and is available; false otherwise.

is-declared-collection#1

declare function cddl:is-declared-collection(
    $name as xs:QName
) as xs:boolean external

Gers whether a collection was declared in the prolog of the static context.

Parameters

  • $name

    The name of the collection to check.

Returns

  • xs:boolean

    true if the collection was declared; false otherwise.