This page was generated
August  8,  2011
2:24  AM
XQuery Built-In and Modules Function Reference

Module: Domains

The domains module is installed as part of the Content Processing Framework. These functions are used to manage domains, which define the association of content processing with particular collections, directories, or documents.

To use the domains module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace dom = "http://marklogic.com/cpf/domains" at "/MarkLogic/cpf/domains.xqy"

The library namespace prefix dom is not predefined in the server.

These functions should be executed in the context of the triggers database.

Function Summary
dom:add-permissions Add permissions to the domain.
dom:add-pipeline Add another pipeline to the set of pipelines bound to the domain.
dom:collection Return the name of the collection in which domains are stored.
dom:configuration-create Create a new CPF configuration.
dom:configuration-get Returns the CPF configuration.
dom:configuration-set-default-domain Set a new default domain for the CPF configuration.
dom:configuration-set-evaluation-context Set a new context for the CPF configuration.
dom:configuration-set-permissions Set new permissions for the CPF configuration.
dom:configuration-set-restart-user Set a new restart user for the CPF configuration.
dom:create Create a new content processing domain, along with the triggers that perform work in that domain.
dom:domain-scope Create a domain scope element.
dom:domains Return all the domains.
dom:evaluation-context Create an evaluation context element.
dom:get Find a particular domain.
dom:remove Remove the domain and any associated triggers.
dom:remove-permissions Remove permissions to the domain.
dom:remove-pipeline Remove the association between a pipeline and the domain.
dom:set-description Set the description of the domain.
dom:set-domain-scope Set the scope of the domain.
dom:set-evaluation-context Set the evaluation context of the domain.
dom:set-name Set the name of the domain to something else.
dom:set-permissions Set the permissions of the domain.
dom:set-pipelines Bind a new set of pipelines to the domain.
Function Detail
dom:add-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Add permissions to the domain. An error is raised if the domain cannot be found. The triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : Additional permissions for the domain.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:add-permissions( "Incoming", 
		       xdmp:permission("development", "read") )
  

dom:add-pipeline(
$domain-name as xs:string,
$pipeline-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Add another pipeline to the set of pipelines bound to the domain. An error is raised if the domain cannot be found or the pipeline does not exist.

Parameters:
$domain-name : The name of the domain to be changed.
$pipeline-id : The unique id of the pipeline.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy"

  dom:add-pipeline( "Incoming", 
		  p:get("Entity Extraction")/p:pipeline-id )
  

dom:collection(  ) as  xs:string
Summary:

Return the name of the collection in which domains are stored.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:collection()
      ==> returns "http://marklogic.com/cpf/domains"
  

dom:configuration-create(
$restart-user as xs:string,
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*
)  as   xs:unsignedLong
Summary:

Create a new CPF configuration.

Parameters:
$restart-user : The username for the user who runs the restart trigger.
$evaluation-context : The evaluation-context element (for example, from the output of dom:evaluation-context for the domain.
$default-domain : The ID of the default domain.
$permissions : Zero or more permissions elements.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-create( "admin", 
   dom:evaluation-context( xdmp:database("Modules"), "/" ),
   fn:data(dom:get("my-domain")/dom:domain-id), 
   (xdmp:permission('my-role', 'read'), 
   xdmp:permission('my-role', 'execute') )
)
  

dom:configuration-get(  ) as  element(dom:configuration)
Summary:

Returns the CPF configuration.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-get()
  

dom:configuration-set-default-domain(
$domain-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Set a new default domain for the CPF configuration.

Parameters:
$domain-id : The domain ID of the default domain.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-default-domain( 
   fn:data(dom:get("my-domain")/dom:domain-id) )
  

dom:configuration-set-evaluation-context(
$context as element(dom:evaluation-context)
)  as   empty-sequence()
Summary:

Set a new context for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$context : An evaluation-context element (for example, from the output of dom:evaluation-context.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-evaluation-context( 
     dom:evaluation-context( xdmp:database("Modules"), "/" ) )
  

dom:configuration-set-permissions(
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Set new permissions for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$permissions : The permissions for the configuration.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-permissions( (xdmp:permission('my-role', 'read'), 
   xdmp:permission('my-role', 'execute') ) )
  

dom:configuration-set-restart-user(
$restart-user as xs:string
)  as   empty-sequence()
Summary:

Set a new restart user for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$restart-user : The username for the restart user.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-restart-user( "admin" )
  

dom:create(
$name as xs:string,
$description as xs:string,
$scope as element(dom:domain-scope),
$context as element(dom:evaluation-context),
$pipelines as xs:unsignedLong*,
$permissions as element(sec:permission)*
)  as   xs:unsignedLong
Summary:

Create a new content processing domain, along with the triggers that perform work in that domain.

Parameters:
$name : The name of the domain. It must be unique.
$description : A description of the domain.
$scope : The scope of the domain. Create using dom:domain-scope.
$context : The evaluation context for processing actions. Create using dom:evaluation-context.
$pipelines : The unique identifiers of the pipelines to bind to this domain. The same pipeline can be bound to different domains. Until at least one pipeline is bound to the domain, no processing is defined for that domain.
$permissions : Permissions.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:create( "Incoming", "Handling incoming documents", 
              dom:domain-scope( "directory", 
                    "/incoming/", 
		    "infinity" ),
	      dom:evaluation-context( xdmp:database("Modules"), 
		                     "/" ),
              (), () )
  

dom:domain-scope(
$document-scope as xs:string,
$uri as xs:string,
$depth as xs:string?
)  as   element(dom:domain-scope)
Summary:

Create a domain scope element.

Parameters:
$document-scope : The way in which this domain scope is defined: "collection", "directory", or "document".
$uri : The URI defining the scoping. For a "collection" scope this will be the collection URI; for a "directory" scope this will be the URI of the directory (and must therefore end with a trailing slash); for a "document" scope this will be the URI of the document.
$depth : This parameter applies only to "directory" scopes and defines whether the scope is recursive ("infinity") or not ("0").

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-domain-scope( "Test", 
                       dom:domain-scope( "document", 
                          "http://example.com/test.xml", 
		          () )
  )
  

dom:domains(  ) as  element(dom:domain)*
Summary:

Return all the domains.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  for $domain in dom:domains()
  return $domain/dom:domain-name
  

dom:evaluation-context(
$database as xs:unsignedLong,
$root as xs:string
)  as   element(dom:evaluation-context)
Summary:

Create an evaluation context element.

Parameters:
$database : The unique identifier of the database in which the content processing actions will be executed. All the modules used in the content processing application must be in this database.
$root : A root path under which modules are located.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-evaluation-context( "Test", 
     dom:evaluation-context( xdmp:database("Modules"), "/" )
  )
  

dom:get(
$domain-name as xs:string
)  as   element(dom:domain)
Summary:

Find a particular domain.

Parameters:
$domain-name : The name of the domain to get. An error is raised if no such domain exists.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:get( "Incoming" )
  

dom:remove(
$domain-name as xs:string
)  as   empty-sequence()
Summary:

Remove the domain and any associated triggers. An error is raised if no such domain exists.

Parameters:
$domain-name : The name of the domain to remove.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:remove( "Incoming" )
  

dom:remove-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Remove permissions to the domain. An error is raised if the domain cannot be found. The triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : Permissions to remove.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:remove-permissions( "Incoming", 
		          xdmp:permission("development", "read") )
  

dom:remove-pipeline(
$domain-name as xs:string,
$pipeline-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Remove the association between a pipeline and the domain. An error is raised if the domain cannot be found. Only the association between the domain and the pipeline will be broken: the existing pipeline will not be deleted and may still be active in other domains.

Parameters:
$domain-name : The name of the domain to be changed.
$pipeline-id : The pipeline to be removed from the domain.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy"

  dom:remove-pipeline( "Incoming", p:get("My Pipeline"/p:pipeline-id )
  

dom:set-description(
$domain-name as xs:string,
$description as xs:string
)  as   empty-sequence()
Summary:

Set the description of the domain. An error is raised if the domain cannot be found.

Parameters:
$domain-name : The name of the domain to be changed.
$description : The new description of the domain.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-description( "Incoming", 
		       "Incoming document processing area" )
  

dom:set-domain-scope(
$domain-name as xs:string,
$scope as element(dom:domain-scope)
)  as   empty-sequence()
Summary:

Set the scope of the domain. An error is raised if the domain cannot be found. If the domain already has triggers associated with it, the triggers will be modified to act on the new scope as well.

Parameters:
$domain-name : The name of the domain to be changed.
$scope : The new scope of the domain. Create using dom:domain-scope.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-domain-scope( "Incoming", 
       dom:domain-scope( "directory", "/incoming/", "0" )
  )
  

dom:set-evaluation-context(
$domain-name as xs:string,
$context as element(dom:evaluation-context)
)  as   empty-sequence()
Summary:

Set the evaluation context of the domain. An error is raised if the domain cannot be found. If the domain already has triggers associated with it, the triggers will be modified to act in the new evaluation context.

Parameters:
$domain-name : The name of the domain to be changed.
$context : The new evaluation context of the domain. Create using dom:evaluation-context.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-evaluation-context( "Incoming", 
       dom:evaluation-context( xdmp:database("Modules"), "/apps/" )
  )
  

dom:set-name(
$domain-name as xs:string,
$new-name as xs:string
)  as   empty-sequence()
Summary:

Set the name of the domain to something else. An error is raised if a domain with the new name already exists or if the domain cannot be found.

Parameters:
$domain-name : The name of the domain whose name will be changed.
$new-name : The new name for this domain.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-name( "Test", "Incoming" )
  

dom:set-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Set the permissions of the domain. An error is raised if the domain cannot be found. If the triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : New permissions for the domain.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"

  dom:set-permissions( "Incoming", xdmp:default-permissions() )
  )
  

dom:set-pipelines(
$domain-name as xs:string,
$pipelines as xs:unsignedLong*
)  as   empty-sequence()
Summary:

Bind a new set of pipelines to the domain. An error is raised if the domain cannot be found or any of the pipelines does not exist. If the domain already has pipelines associated with it, those existing pipelines will not be deleted; only the association will be broken.

Parameters:
$domain-name : The name of the domain to be changed.
$pipelines : The unique ids of the pipelines.

Example:
  xquery version "0.9-ml"
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy"
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy"

  dom:set-pipelines( "Incoming", (
     p:get("Status Change Handling")/p:pipeline-id,
     p:get("Basic Conversion")/p:pipeline-id ) )