http://zorba.io/modules/store/dynamic/collections/w3c/ddl

Description

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

import module namespace ddl = "http://zorba.io/modules/store/dynamic/collections/w3c/ddl";
This modules defines a set of functions for managing persistent, ordered, and updatable collections.

Such collections are identified by a URI as defined in the XQuery specification. However, please note that we do not advise users to use collections identified by URIs. Instead, we refer to the data lifecycle documentation. It gives an overview of several ways to work with collections, documents, and other data-structures.

Module code

Here is the actual XQuery module code.

Imported modules

See also

Authors

Matthias Brantner, David Graf, Till Westmann, Markos Zaharioudakis

Version Declaration

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

Namespaces

ddlhttp://zorba.io/modules/store/dynamic/collections/w3c/ddl
qddlhttp://zorba.io/modules/store/dynamic/collections/ddl
verhttp://zorba.io/options/versioning
zerrhttp://zorba.io/errors

Function Summary

to-qname($uri as xs:string) as xs:QName

THIS FUNCTION IS FOR INTERNAL USE ONLY.

from-qname($name as xs:QName) as xs:string

THIS FUNCTION IS FOR INTERNAL USE ONLY.

is-available-collection($uri as xs:string) as xs:boolean

Checks whether a collection with the given URI exists.

available-collections() as xs:string*

The function returns a sequence of URIs of the collections that are available.

create($uri as xs:string)

Creates the collection with the given URI.

create($uri as xs:string, $content as node()*)

Creates the collection with the given URI and adds copies of the given sequence to the new collection.

delete($uri as xs:string)

Deletes the collection with the given URI.

Functions

to-qname#1

declare function ddl:to-qname(
    $uri as xs:string
) as xs:QName

THIS FUNCTION IS FOR INTERNAL USE ONLY. Converts a URI given as a string into a reserved QName. This QName is used in the module to be able to store collections identified by URIs using dynamic collections that are identified by QNames.

Parameters

  • $uri

    URI to convert to a reserved QName.

Returns

  • xs:QName

    The reserved QName for the given URI.

from-qname#1

declare function ddl:from-qname(
    $name as xs:QName
) as xs:string

THIS FUNCTION IS FOR INTERNAL USE ONLY. Gets the namespace component of the given QName.

Parameters

  • $name

    The QName whose namespace component should be returned.

Returns

  • xs:string

    The namespace component of $name

is-available-collection#1

declare function ddl:is-available-collection(
    $uri as xs:string
) as xs:boolean

Checks whether a collection with the given URI exists.

Parameters

  • $uri

    The URI of the collection to check.

Returns

  • xs:boolean

    true if the collection is available and false otherwise.

available-collections#0

declare function ddl:available-collections() as xs:string*

The function returns a sequence of URIs of the collections that are available. The sequence will be empty if there are no collections.

Returns

  • xs:string*

    A sequence of URIs, one for each available collection, or an emtpy sequence.

create#1

declare updating function ddl:create(
    $uri as xs:string
) as item()*

Creates the collection with the given URI.

Parameters

  • $uri

    The URI of the collection to create.

Errors

  • zerr:ZDDY0002

    if a collection identified by $uri already exists.

create#2

declare updating function ddl:create(
    $uri as xs:string,
    $content as node()*
) as item()*

Creates the collection with the given URI and adds copies of the given sequence to the new collection.

Parameters

  • $uri

    The URI of the collection to create.

  • $content

    The sequence of nodes to add to the new collection.

Errors

  • zerr:ZDDY0002

    if a collection identified by $uri already exists.

delete#1

declare updating function ddl:delete(
    $uri as xs:string
) as item()*

Deletes the collection with the given URI.

Parameters

  • $uri

    The URI of the collection to delete.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

  • zerr:ZDDY0015

    if any of the in-scope variables reference a node that belongs to the collection identified by $uri.