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

Description

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

import module namespace dml = "http://zorba.io/modules/store/dynamic/collections/w3c/dml";
This modules provides a set of functions to modify a collection and retrieve the nodes contained in a particular collection.

Such collections are identified by a URI as defined in the XQuery specification. However, please note that we do not advice 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

anhttp://zorba.io/annotations
ddlhttp://zorba.io/modules/store/dynamic/collections/w3c/ddl
dmlhttp://zorba.io/modules/store/dynamic/collections/w3c/dml
qdmlhttp://zorba.io/modules/store/dynamic/collections/dml
verhttp://zorba.io/options/versioning
zerrhttp://zorba.io/errors

Function Summary

insert-nodes-first($name as xs:string, $content as node()*)

Inserts copies of the given nodes at the beginning of the collection.

insert-nodes-last($name as xs:string, $content as node()*)

Inserts copies of the given nodes at the end of the collection.

insert-nodes-before($name as xs:string, $target as node(), $content as node()*)

Inserts copies of the given nodes into a collection at the position directly preceding the given target node.

insert-nodes-after($name as xs:string, $pos as node(), $content as node()*)

Inserts copies of the given nodes into a collection at the position directly following the given target node.

apply-insert-nodes-first($name as xs:string, $content as node()*) as node()*

This function does the same as the insert-nodes() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

apply-insert-nodes-last($name as xs:string, $content as node()*) as node()*

This function does the same as the insert-nodes-last() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

apply-insert-nodes-before($name as xs:string, $target as node(), $content as node()*) as node()*

This function does the same as the insert-nodes-before() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

apply-insert-nodes-after($name as xs:string, $pos as node(), $content as node()*) as node()*

This function does the same as the insert-nodes-after() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

collection($name as xs:string) as node()*

Gets the sequence of nodes of the collection identified by the given name.

collection-name($node as node()) as xs:string

Gets the name of the collection the given node belongs to.

delete-nodes($nodes as node()*)

Deletes nodes from a collection.

delete-node-first($name as xs:string)

Deletes the first node from a collection.

delete-nodes-first($name as xs:string, $number as xs:integer)

Deletes the first N nodes from a collection.

delete-node-last($name as xs:string)

Deletes the last node from a collection.

delete-nodes-last($name as xs:string, $number as xs:integer)

Deletes the last N nodes from a collection.

index-of($node as node()) as xs:integer

Gets the index of the given node in the collection.

Functions

insert-nodes-first#2

declare updating function dml:insert-nodes-first(
    $name as xs:string,
    $content as node()*
) as item()*

Inserts copies of the given nodes at the beginning of the collection.

Parameters

  • $name

    The name of the collection to insert into.

  • $content

    The sequence of nodes whose copies will be inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

insert-nodes-last#2

declare updating function dml:insert-nodes-last(
    $name as xs:string,
    $content as node()*
) as item()*

Inserts copies of the given nodes at the end of the collection.

Parameters

  • $name

    The name of the collection to insert into.

  • $content

    The sequence of nodes whose copies will be inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

insert-nodes-before#3

declare updating function dml:insert-nodes-before(
    $name as xs:string,
    $target as node(),
    $content as node()*
) as item()*

Inserts copies of the given nodes into a collection at the position directly preceding the given target node.

Parameters

  • $name

    The name of the collection to insert into.

  • $target

    The node in the collection before which $content will be inserted.

  • $content

    The sequences of nodes whose copies will be inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

  • zerr:ZDDY0011

    if $target node is not contained in the collection.

insert-nodes-after#3

declare updating function dml:insert-nodes-after(
    $name as xs:string,
    $pos as node(),
    $content as node()*
) as item()*

Inserts copies of the given nodes into a collection at the position directly following the given target node.

Parameters

  • $name

    The name of the collection to insert into.

  • $target

    The node in the collection after which $content will be inserted.

  • $content

    The sequence of nodes whose copies will be inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

  • zerr:ZDDY0011

    if $target node is not contained in the collection.

apply-insert-nodes-first#2

declare %an:sequential function dml:apply-insert-nodes-first(
    $name as xs:string,
    $content as node()*
) as node()*
This function does the same as the insert-nodes() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

Parameters

  • $name

    The name of the collection to insert into.

  • $content

    The sequence of nodes whose copies will be inserted.

Returns

  • node()*

    The sequence of nodes that have been inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

apply-insert-nodes-last#2

declare %an:sequential function dml:apply-insert-nodes-last(
    $name as xs:string,
    $content as node()*
) as node()*
This function does the same as the insert-nodes-last() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

Parameters

  • $name

    The name of the collection to insert into.

  • $content

    The sequence of nodes whose copies will be inserted.

Returns

  • node()*

    The sequence of nodes that have been inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

apply-insert-nodes-before#3

declare %an:sequential function dml:apply-insert-nodes-before(
    $name as xs:string,
    $target as node(),
    $content as node()*
) as node()*
This function does the same as the insert-nodes-before() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

Parameters

  • $name

    The name of the collection to insert into.

  • $target

    The node in the collection before which $content will be inserted.

  • $content

    The sequence of nodes whose copies will be inserted.

Returns

  • node()*

    The sequence of nodes that have been inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

apply-insert-nodes-after#3

declare %an:sequential function dml:apply-insert-nodes-after(
    $name as xs:string,
    $pos as node(),
    $content as node()*
) as node()*
This function does the same as the insert-nodes-after() function except it immediately applies the resulting pending updates and returns the nodes that have been inserted.

Parameters

  • $name

    The name of the collection to insert into.

  • $target

    The node in the collection after which $content will be inserted.

  • $content

    The sequence of nodes whose copies will be inserted.

Returns

  • node()*

    The sequence of nodes that have been inserted.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

collection#1

declare function dml:collection(
    $name as xs:string
) as node()*

Gets the sequence of nodes of the collection identified by the given name.

Parameters

  • $name

    The name of the collection.

Returns

  • node()*

    The sequence contained in the given collection.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

collection-name#1

declare function dml:collection-name(
    $node as node()
) as xs:string

Gets the name of the collection the given node belongs to.

Parameters

  • $node

    The node for which to get the name of the collection.

Returns

  • xs:string

    The URI of the collection to which $node belongs.

Errors

  • zerr:ZDDY0011

    if $node does not belong to a collection.

delete-nodes#1

declare updating function dml:delete-nodes(
    $nodes as node()*
) as item()*

Deletes nodes from a collection.

Parameters

  • $nodes

    the nodes in the collection that should be deleted.

Errors

  • zerr:ZDDY0011

    if any nodes are not a member of a collection or not all nodes of belong to the same collection.

delete-node-first#1

declare updating function dml:delete-node-first(
    $name as xs:string
) as item()*

Deletes the first node from a collection.

Parameters

  • $name

    The name of the collection to delete from.

Errors

  • zerr:ZDDY0011

    if the collection is empty.

delete-nodes-first#2

declare updating function dml:delete-nodes-first(
    $name as xs:string,
    $number as xs:integer
) as item()*
Deletes the first N nodes from a collection.

Parameters

  • $name

    The name of the collection to delete from.

  • $number

    The number of nodes to delete.

Errors

  • zerr:ZDDY0011

    if the collection contains less than $number items.

delete-node-last#1

declare updating function dml:delete-node-last(
    $name as xs:string
) as item()*

Deletes the last node from a collection.

Parameters

  • $name

    The name of the collection to delete from.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

  • zerr:ZDDY0011

    if the collection is empty.

delete-nodes-last#2

declare updating function dml:delete-nodes-last(
    $name as xs:string,
    $number as xs:integer
) as item()*
Deletes the last N nodes from a collection.

Parameters

  • $name

    The name of the collection to delete from.

  • $number

    The number of nodes to delete.

Errors

  • zerr:ZDDY0003

    if the collection is not available.

  • zerr:ZDDY0011

    if the collection contains less than $number items.

index-of#1

declare function dml:index-of(
    $node as node()
) as xs:integer

Gets the index of the given node in the collection.

Parameters

  • $node

    The node to get the index of.

Returns

  • xs:integer

    Returns the position of $node in the collection.

Errors

  • zerr:ZDDY0011

    if $node is not contained in any collection.