XQuery Function Documentation

Search and Browse

v:annotate

v:annotate($doc as node(), $rev as xs:integer) as item()*

Return an XML document in which all changes between $rev and $rev - 1 are annotated.

Parameters:
$doc a node in the document which should be annotated
$rev the revision whose changes will be annotated
Returns:
item()*

v:apply-patch

v:apply-patch($doc as node(), $diffs as element()*) as item()*

Apply a given patch on a document. This function is used by v:doc internally.

Parameters:
$doc $doc
$diffs* $diffs*
Returns:
item()*

v:diff

v:diff($doc as node(), $rev as xs:integer) as element()?

For the document passed as first argument, retrieve the revision specified in the second argument. Generate a diff between both version, i.e. HEAD and the given revision. The empty sequence is returned if the given revision is invalid, i.e. v:doc returns the empty sequence.

Parameters:
$doc a node in the document for which the diff should be generated
$rev a valid revision number
Returns:
element()?

v:doc

v:doc($doc as node(), $rev as xs:integer?) as node()*

Restore a certain revision of a document by applying a sequence of diffs and return it as an in-memory node. If the revision argument is empty or smaller than the first actual revision of the document, the function will return the base version of the document. If the revision number is greater than the latest revision, the latest version will be returned.

Parameters:
$doc a node in the document for which a revision should be retrieved.
$rev? the revision which should be restored
Returns:
node()* : a sequence of nodes corresponding to the restored document (TODO: return a document node instead?)

v:find-newer-revision

v:find-newer-revision($doc as node(), $base as xs:integer, $key as xs:string) as element()?

Check if there are any revisions in the database which are newer than the version identified by the specified base revision and key. If versioning is active, the base revision and key are added to the document root element as attributes whenever a document is serialized. The combination of the two attributes allows eXist to determine if a newer revision of the document exists in the database, which usually means that another user/client has committed it in the meantime.
If one or more newer revisions exist in the database, v:find-newer-revision will return the version document of the newest revision or an empty sequence otherwise.

Parameters:
$doc a node in the document which should be checked
$base the base revision as provided in the v:revision attribute of the document which was retrieved from the db.
$key the key as provided in the v:key attribute of the document which was retrieved from the db.
Returns:
element()? : a v:version element or the empty sequence if there's no newer revision in the database

v:history

v:history($doc as node()) as element()

Returns an XML fragment showing the version history of the document to which the specified node belongs. All revisions are listed with date and user, but without the detailed diff.

Parameters:
$doc an arbitrary node in a document
Returns:
element()

v:revisions

v:revisions($doc as node()) as xs:integer*

Parameters:
$doc $doc
Returns:
xs:integer*

v:versions

v:versions($doc as node()) as element()*

Return all version docs, including the full diff, for the specified document. This is mainly for internal use.

Parameters:
$doc a node in the document for which revisions should be retrieved.
Returns:
element()* : zero or more v:version elements describing the changes made in a revision.