MarkLogic 9 Product Documentation
view functions

The table below lists all the view built-in functions (in this namespace: http://marklogic.com/xdmp/view).

The views module is used to create and manage SQL schemas and views. This API only creates and manages Range Views, as described in Creating Range Views in the SQL Data Modeling Guide. The functions in this API will not work on Template Views, as described in Creating Template Views in the SQL Data Modeling Guide.

A schema defines a logical scoping for views. A schema has a unique ID, a name (which must also be unique), and a collection of views. During SQL execution, the schema provides the naming context for its views, which enables you have have multiple views of the same name in different schemas. The default schema is called "main". Even though it is a default, you must create the "main" schema before it can be used.

A view is an abstraction of a SQL "table." However, unlike in a relational database, a view in MarkLogic server is implemented on top of element range indexes. A view consists of a unique ID, a name (which must be unique in the context of a particular schema), a view scope, and a sequence of column specifications. Each column has a name and a range index reference. The range index for each column must be created before creating the view. The view scope is used to constrain the subset of the database to which the view applies. The view scope can either limit rows in the view to documents with a specific element (localname + namespace) or to documents in a particular collection.

The views function module is installed as the following file:

where install_dir is the directory in which MarkLogic Server is installed.

To use the views.xqy module in your own XQuery modules, include the following line in your XQuery prolog:

import module namespace view="http://marklogic.com/xdmp/view" at "/MarkLogic/views.xqy";

You must have the view-admin role to execute the functions in the View library.

37 functions
Function name Description
view.addColumn This function adds column specifications to the current set of column specifications on the named view in the named schema.
view.addField This function adds a field to the named view.
view.addPermissions This function adds permissions to those already set for the named view in the named schema specification.
view.collection This function return the URI of the protected collection holding all the views.
view.collectionViewScope This function constructs a new collection-style view scope specification.
view.column This function constructs a new column specification.
view.columns This function returns the sequence of column specifications set in the named view in the named schema.
view.create This function creates a new view in the specified schema specification.
view.elementViewScope This function constructs a new element-style view scope specification.
view.field This function constructs a new element-style field specification for the named field.
view.fields This function returns the fields set on the named view.
view.get This function returns the named view from the named schema specification.
view.getBindings This function generates a binding map suitable for use with cts:parse from the named view.
view.getById This function returns the view with the specified id.
view.getColumn This function returns the named column specification set in the named view in the named schema.
view.getField This function returns the element specification for the named field.
view.getPermissions This function returns the permissions set on the specified view.
view.getViewScope This function returns the scope of the named view in the named schema.
view.remove This function removes the named view from the named schema specification.
view.removeById This function removes the view with the specified id.
view.removeColumn This function removes a column specification from the named view in the named schema.
view.removeField This function removes a field from the named view.
view.removePermissions This function removes permissions from those set for the named view in the named schema specification.
view.schemaAddPermissions This function adds permissions to the specified schema specification.
view.schemaCreate This function creates a new relational schema in the Schema database.
view.schemaGet This function returns the named schema specification document.
view.schemaGetPermissions This function returns the permissions set on the specified schema.
view.schemaRemove This function removes the specified schema.
view.schemaRemovePermissions This function removes permissions from the specified schema specification.
view.schemas This function returns all of the schema specifications.
view.schemaSetPermissions This function sets permissions on the specified schema specification.
view.setColumns This function replaces the current set of column specifications on the named view in the named schema with a new set of columns.
view.setFields This function sets the specified fields on the specified view.
view.setName This function renames the named view in the named schema specification.
view.setPermissions This function sets the permissions for the named view in the named schema specification.
view.setViewScope This function sets the scope of the named view in the named schema specification.
view.views This function returns all of the view specifications in the named schema.
Powered by MarkLogic Server | Terms of Use | Privacy Policy