| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:01 AM | XQuery & XSLT Built-In & Modules Function Reference
Module: Triggers
The triggers function module is installed as the following file: `install_dir/Modules/MarkLogic/triggers.xqy` where `install_dir` is the directory in which MarkLogic Server is installed. To use the `triggers.xqy` module in your own XQuery modules, include the following line in your XQuery prolog: `import module namespace trgr="http://marklogic.com/xdmp/triggers" at "/MarkLogic/triggers.xqy";` The triggers module is used for manually creating and managing triggers. If you use the Content Processing Framework, it automatically creates and manages the triggers. The function to create a new trigger, `trgr:create-trigger`, uses the other trigger functions to construct the trigger XML document and insert it into the triggers database. The trigger functions should all be run against the triggers database of the database in which the content is stored. For more information on using triggers, see "Using Triggers to Spawn Actions" in the Application Developer's Guide.
Function Summary
trgr:any-property-content | Returns the XML representation of an all-properties part to a triggering event, usable as the content parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:collection-scope | Returns the XML representation of a collection scope, usable as the scope parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:create-trigger | Creates a new trigger in the context database.
trgr:directory-scope | Returns the XML representation of a directory scope, usable as the scope parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:document-content | Returns the XML representation of a document part of a triggering event, usable as the content parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:document-scope | Returns the XML representation of a document scope, usable as the scope parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:get-trigger | Returns the XML representation of a trigger with the given name.
trgr:get-trigger-by-id | Returns the XML representation of the trigger with the given trigger id.
trgr:post-commit | Returns the XML representation of a post-commit trigger timing.
trgr:pre-commit | Returns the XML representation of a pre-commit trigger timing.
trgr:property-content | Returns the XML representation of a property part to a triggering event, usable as the content parameter of a trigger event constructor such as trgr:trigger-data-event.
trgr:remove-trigger | Removes the named trigger.
trgr:trigger-add-permissions | Adds permissions to the set of permissions on the named trigger.
trgr:trigger-data-event | Returns the XML representation of a triggering eventa, usable as the event parameter of trgr:create-trigger.
trgr:trigger-database-online-event | Returns the XML representation of a database coming online event, usable as the event parameter of trgr:create-trigger.
trgr:trigger-disable | Disables the named trigger.
trgr:trigger-enable | Enables the named trigger.
trgr:trigger-get-permissions | Returns the permissions for the named trigger.
trgr:trigger-module | Returns the XML representation of a trigger module which can be used as the module parameter of trgr:create-trigger.
trgr:trigger-remove-permissions | Removes a set of permissions from the set of permissions on the named trigger.
trgr:trigger-set-description | Sets the description of the named trigger.
trgr:trigger-set-event | Assigns a triggering event to the named trigger.
trgr:trigger-set-module | Sets or replaces the action module associated with the named trigger.
trgr:trigger-set-name | Changes the name of a trigger.
trgr:trigger-set-permissions | Sets the permissions that determine which roles are permitted to modify the named trigger.
trgr:trigger-set-recursive | Sets the recursive setting of the identified trigger.
Function Detail
trgr:any-property-content( ) as element(trgr:any-property-content)
Summary: Returns the XML representation of an all-properties part to a triggering event, usable as the content parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Usage Notes: Adding, changing or removing any document property matches this event part.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:directory-scope("/myDir/", "1"),
      trgr:any-property-content(),
      trgr:post-commit())

      => A property modification trigger event that can
         be used to create a trigger which fires whenever any
         property is added, changed or removed on a document
         in the /myDir/ directory.
trgr:collection-scope(
| $uri as xs:string
) as element(trgr:collection-scope)
Summary: Returns the XML representation of a collection scope, usable as the scope parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Parameters:
$uri : The collection uri.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:collection-scope("/myCollecion/"),
      trgr:document-content("modify"),
      trgr:post-commit())

      => A collection modification trigger event
         that can be used to create a trigger which fires
         whenever the /myCollection/ collection is modified.
trgr:create-trigger(
| $trigger-name as xs:string,
| $description as xs:string?,
| $event as element(),
| $module as element(trgr:module),
| $enabled as xs:boolean,
| $permissions as element(sec:permission)*,
| [$recursive as xs:boolean?]
) as xs:unsignedLong
Summary: Creates a new trigger in the context database. Returns the trigger ID of the created trigger.
Parameters:
$trigger-name : A unique name. If $trigger-name is not unique, an error is returned.
$description : A description of the trigger.
$event : The definition of an event that invokes the trigger module. Use `trgr:trigger-data-event` or `trgr:trigger-database-online-event` to construct this element.
$module : The module to execute when the triggering event occurs. Use `trgr:trigger-module` to construct this element.
$enabled : Set to true if the trigger is enabled.
$permissions : A sequence of permissions for the trigger. These permissions will determine which roles are permitted to modify the trigger.
$recursive (optional): Set to true if the trigger should be allowed to trigger itself for recursive changes on the same document. Set to false to prevent the trigger from triggering itself. If this parameter is not present, then its value is true.
Required Privilege: `http://marklogic.com/xdmp/privileges/create-trigger`
Usage Notes: Triggers must be created in the triggers database associated with the the content database to which the triggers apply. To determine the triggers database programatically, use `xdmp:triggers-database` in the evaluation context of the content database, or `xdmp:database` with the database name listed as the `triggers database` value in the Admin Interface under Databases > content_db_name. Triggers are created in the `http://marklogic.com/xdmp/triggers/` directory, with the trigger ID completing the URI. This is the ID returned by `trgr:create-trigger`. If a trigger named $trigger-name already exists, the exception `TRGR-TNEXISTS` is raised. You must use `trgr:remove-trigger` to delete an existing trigger before recreating it. Once a trigger is created, you can view it in the Admin Interface under the content database, in the Triggers Summary page (Databases > content_db_name > Triggers). If your trigger does not appear in Triggers Summary, `trgr:create-trigger` was probably evaluated in the wrong database context.
Example:
    (: Run in the context of the triggers database of the content database :)
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:create-trigger("myTrigger", "Simple trigger example",
      trgr:trigger-data-event(
          trgr:directory-scope("/myDir/", "1"),
          trgr:document-content("create"),
          trgr:post-commit()),
      trgr:trigger-module(xdmp:database("test"), "/modules/", "log.xqy"),
      fn:true(), xdmp:default-permissions() )

      => The ID of the newly created trigger. This
         trigger fires whenever a document is created in the
         /myDir/ directory. The action module, /modules/log.xqy,
         is stored in the modules database of the App Server
         against which the content document is created.  When
         the trigger fires, a task to evaluate /modules/log.xqy
         is spawned on the task server queue.
trgr:directory-scope(
| $uri as xs:string,
| $depth as xs:string
) as element(trgr:directory-scope)
Summary: Returns the XML representation of a directory scope, usable as the scope parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Parameters:
$uri : The directory uri.
$depth : The depth of descendants included in the scope. ("1" or "infinity")
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:directory-scope("/myDir/", "1"),
      trgr:document-content("modify"),
      trgr:post-commit())

      => A directory modification trigger event that may
         be used to create a trigger which fires whenever
         the /myDir/ directory in a database is modified.
trgr:document-content(
| $update-kind as xs:string
) as element(trgr:document-content)
Summary: Returns the XML representation of a document part of a triggering event, usable as the content parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Parameters:
$update-kind : "create", "modify", or "delete"
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:directory-scope("/myDir/", "1"),
      trgr:document-content("modify"),
      trgr:post-commit())

      => A directory modification trigger event that can
         be used to create a trigger which fires whenever the
         /myDir/ directory in the database is modified.
trgr:document-scope(
| $uri as xs:string
) as element(trgr:document-scope)
Summary: Returns the XML representation of a document scope, usable as the scope parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Parameters:
$uri : The document uri.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:document-scope("/myDir/interesting.xml"),
      trgr:document-content("modify"),
      trgr:post-commit())

      => A collection modification trigger event that may
         be used to create a trigger which fires whenever the
         document with URI /myDir/interesting.xml is modified.
trgr:get-trigger(
| $trigger-name as xs:string
) as element(trgr:trigger)
Summary: Returns the XML representation of a trigger with the given name.
Parameters:
$trigger-name : The trigger name.
Usage Notes: This function must be run in the context of the database containing the trigger to be examined. If no trigger with the name $trigger-name exists, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:get-trigger("myTrigger")

      => <trgr:trigger xmlns:trgr="http://marklogic.com/xdmp/triggers">
           <trgr:trigger-id>7561204940964272849</trgr:trigger-id>
           <trgr:trigger-name>myTrigger</trgr:trigger-name>
           <trgr:description>Simple trigger example</trgr:description>
           <trgr:data-event>
             <trgr:directory-scope>
               <trgr:uri>/myDir/</trgr:uri>
               <trgr:depth>1</trgr:depth>
             </trgr:directory-scope>
             <trgr:document-content>
               <trgr:update-kind>create</trgr:update-kind>
             </trgr:document-content>
             <trgr:when>post-commit</trgr:when>
           </trgr:data-event>
           <trgr:module>
             <trgr:database>10570023054829957732</trgr:database>
             <trgr:root>/modules/</trgr:root>
             <trgr:path>log.xqy</trgr:path>
           </trgr:module>
           <trgr:enabled>true</trgr:enabled>
           <trgr:recursive>true</trgr:recursive>
         </trgr:trigger>
trgr:get-trigger-by-id(
| $trigger-id as xs:unsignedLong
) as element(trgr:trigger)
Summary: Returns the XML representation of the trigger with the given trigger id.
Parameters:
$trigger-id : The trigger id.
Usage Notes: This function must be run in the context of the database containing the trigger to be examined. If no trigger exists with id $trigger-id, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:get-trigger-by-id(7561204940964272849)

      => <trgr:trigger xmlns:trgr="http://marklogic.com/xdmp/triggers">
           <trgr:trigger-id>7561204940964272849</trgr:trigger-id>
           <trgr:trigger-name>myTrigger</trgr:trigger-name>
           <trgr:description>Simple trigger example</trgr:description>
           <trgr:data-event>
             <trgr:directory-scope>
               <trgr:uri>/myDir/</trgr:uri>
               <trgr:depth>1</trgr:depth>
             </trgr:directory-scope>
             <trgr:document-content>
               <trgr:update-kind>create</trgr:update-kind>
             </trgr:document-content>
             <trgr:when>post-commit</trgr:when>
           </trgr:data-event>
           <trgr:module>
             <trgr:database>10570023054829957732</trgr:database>
             <trgr:root>/modules/</trgr:root>
             <trgr:path>log.xqy</trgr:path>
           </trgr:module>
           <trgr:enabled>true</trgr:enabled>
           <trgr:recursive>true</trgr:recursive>
         </trgr:trigger>
trgr:post-commit( ) as element(trgr:when)
Summary: Returns the XML representation of a post-commit trigger timing.
Usage Notes: Use this function with `trgr:trigger-data-event` to create a post-commit trigger event. To learn more about post-commit triggers, see "Using Triggers to Spawn Actions" in the Application Developer's Guide.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:post-commit())
      trgr:trigger-data-event(
        trgr:directory-scope("/myDir/", "1"),
        trgr:document-content("create"),
        trgr:post-commit())

      => A document modification trigger event that can
         be used to create a trigger which fires whenever
         a document is created in /myDir/. The associated
         trigger module executes after committing the
         firing document creation transaction.
trgr:pre-commit( ) as element(trgr:when)
Summary: Returns the XML representation of a pre-commit trigger timing.
Usage Notes: Use this function with `trgr:trigger-data-event` to create a pre-commit trigger event. To learn more about pre-commit triggers, see "Using Triggers to Spawn Actions" in the Application Developer's Guide.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:post-commit())
      trgr:trigger-data-event(
        trgr:directory-scope("/myDir/", "1"),
        trgr:document-content("create"),
        trgr:pre-commit())

      => A document modification trigger event that can
         be used to create a trigger which fires whenever
         a document is created in /myDir/. The associated
         trigger module executes before committing the
         firing document creation transaction.
trgr:property-content(
| $property-name as xs:QName
) as element(trgr:property-content)
Summary: Returns the XML representation of a property part to a triggering event, usable as the content parameter of a trigger event constructor such as `trgr:trigger-data-event`.
Parameters:
$property-name : The QName of the property.
Usage Notes: Adding, changing or removing the $property-name document property matches this event part.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:directory-scope("/myDir/", "1"),
      trgr:property-content(
        fn:qname("", "myInterestingProperty")),
      trgr:post-commit())

      => A property modification trigger event that can
         be used to create a trigger which fires whenever
         the property myInterestingProperty is added, modified
         or removed from a document in /myDir/.
trgr:remove-trigger(
| $trigger-name as xs:string
) as empty-sequence()
Summary: Removes the named trigger.
Parameters:
$trigger-name : The trigger name.
Usage Notes: This function deletes the specified trigger. You must run this function to remove a trigger before recreating it. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:remove-trigger("myTrigger")

      => Empty sequence. Removes the specified trigger from the database.
trgr:trigger-add-permissions(
| $trigger-name as xs:string,
| $permissions as element(sec:permission)*
) as empty-sequence()
Summary: Adds permissions to the set of permissions on the named trigger.
Parameters:
$trigger-name : The trigger name.
$permissions : A sequence of permission nodes.
Usage Notes: Any permissions previously associated with the trigger remain intact. This function must be run in the context of the database containing the trigger to be examined. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-add-permissions(
      "myTrigger",
      (xdmp:permission("some-role", "read"),
       xdmp:permission("some-role", "modify"))
    )
trgr:trigger-data-event(
| $scope as element(),
| $content as element(),
| $when as element(trgr:when)
) as element(trgr:data-event)
Summary: Returns the XML representation of a triggering eventa, usable as the event parameter of `trgr:create-trigger`.
Parameters:
$scope : An event scope, such as is created by `trgr:directory-scope`, `trgr:collection-scope`, or `trgr:document-scope`.
$content : An event part, such as is created by `trgr:document-content`, `trgr:property-content`, or `trgr:any-property-content`.
$when : The timing of the trigger execution (pre- or post-commit). Use `trgr:post-commit` or `trgr:pre-commit` to construct this element.
Usage Notes: The scope parameter describes the set of documents to which the trigger event applies. The content parameter describes the interesting activity within scope, such as document creation or document property modification. The when parameter describes when the event should be acted on, relative to the triggering transaction.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-data-event(
      trgr:directory-scope("/myDir/", "1"),
      trgr:document-content("create"),
      trgr:post-commit()
    )

      => A trigger event suitable for use with trgr:create-trigger.
         The triggering event occurs at post-commit whenever a document
         is created in the database directory "/myDir/".
trgr:trigger-database-online-event(
| $user-name as xs:string
) as element(trgr:database-online-event)
Summary: Returns the XML representation of a database coming online event, usable as the event parameter of `trgr:create-trigger`.
Parameters:
$user-name : The user used to execute the trigger module.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-database-online-event("database-admin")

      => A trigger event suitable for use with trgr:create-trigger.
         The triggering event occurs whenever a (unspecified) database
         comes online. The trigger module associated with this event
         executes as user "database-admin".
trgr:trigger-disable(
| $trigger-name as xs:string
) as empty-sequence()
Summary: Disables the named trigger.
Parameters:
$trigger-name : The trigger name.
Usage Notes: This function must be run in the context of the database containing the trigger to be disabled. If no trigger named $trigger-name exists, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-disable("the_trigger_name")
trgr:trigger-enable(
| $trigger-name as xs:string
) as empty-sequence()
Summary: Enables the named trigger.
Parameters:
$trigger-name : The trigger name.
Usage Notes: This function must be run in the context of the database containing the trigger to be enabled. If no trigger named $trigger-name exists, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-enable("the_trigger_name")
trgr:trigger-get-permissions(
| $trigger-name as xs:string
) as element(sec:permission)*
Summary: Returns the permissions for the named trigger.
Parameters:
$trigger-name : The trigger name.
Usage Notes: The permissions on a trigger determine which roles may modify the trigger. This function must be run in the context of the database containing the trigger to be examined. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-get-permissions("myTrigger")

      => <sec:permission xmlns:sec="http://marklogic.com/xdmp/security">
           <sec:capability>update</sec:capability>
           <sec:role-id>6991745490888355329</sec:role-id>
         </sec:permission>
         <sec:permission xmlns:sec="http://marklogic.com/xdmp/security">
           <sec:capability>read</sec:capability>
           <sec:role-id>6991745490888355329</sec:role-id>
         </sec:permission>
trgr:trigger-module(
| $database-id as xs:unsignedLong,
| $root as xs:string,
| $path as xs:string
) as element(trgr:module)
Summary: Returns the XML representation of a trigger module which can be used as the module parameter of `trgr:create-trigger`.
Parameters:
$database-id : A database-id.
$root : The root path within the database.
$path : The path to the module relative to $root within the database identified by $database-id.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-module(
      xdmp:database("Documents"),
      "/modules/",
      "log-create.xqy")

      => An internal XML representation of the trigger module,
         usable as the module parameter of trgr:create-trigger().
trgr:trigger-remove-permissions(
| $trigger-name as xs:string,
| $permissions as element(sec:permission)*
) as empty-sequence()
Summary: Removes a set of permissions from the set of permissions on the named trigger.
Parameters:
$trigger-name : The trigger name.
$permissions : A sequence of permission nodes.
Usage Notes: This function must be run in the context of the database containing the trigger to be modified. Any permissions on `$trigger-name` not listed in `$permissions` are unchanged. Any permissions in `$permissions` not associated with `$trigger-name` are ignored. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-remove-permissions(
        "myTrigger",
        (xdmp:permission("some-role", "modify"))
    )
trgr:trigger-set-description(
| $trigger-name as xs:string,
| $description as xs:string
) as empty-sequence()
Summary: Sets the description of the named trigger.
Parameters:
$trigger-name : The trigger name.
$description : The new trigger description.
Usage Notes: This function must be run in the context of the database containing the trigger whose description is to be changed. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-set-description("currentName", "the new description")
trgr:trigger-set-event(
| $trigger-name as xs:string,
| $event as element()
) as empty-sequence()
Summary: Assigns a triggering event to the named trigger.
Parameters:
$trigger-name : The trigger name.
$event : An event definition. Use `trgr:trigger-data-event` or `trgr:trigger-database-online-event` to construct this element.
Usage Notes: A trigger event describes the conditions under which the trigger fires. After calling this function, any previous event associated with the trigger is replaced. This function must be run in the context of the database containing the trigger to be modified. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-set-event(
      "myTrigger",
      trgr:trigger-data-event(
        trgr:directory-scope("/myDir/", "1"),
        trgr:document-content("create"),
        trgr:post-commit()) )

      => Empty sequence. The trigger "myTrigger" is set to fire
         whenever a document is created in "/myDir/". The trigger
         module runs after the creating transaction is committed.
trgr:trigger-set-module(
| $trigger-name as xs:string,
| $module as element(trgr:module)
) as empty-sequence()
Summary: Sets or replaces the action module associated with the named trigger.
Parameters:
$trigger-name : The trigger name.
$module : A module definition. Use `trgr:trigger-data-event` to construct this parameter.
Usage Notes: When $trigger fires, $module is evaluated. Any module previously associated with $trigger is replaced when this function is called. This function must be run in the context of the database containing the trigger to be modified. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-set-module(
      "myTrigger",
      trgr:trigger-module(
        xdmp:database("trigger_module_database"),
        "/modules/",
        "the-new-action.xqy") )

      => Empty sequence. When "myTrigger" fires, "the-new-action.xqy"
        is evaluated.
trgr:trigger-set-name(
| $trigger-name as xs:string,
| $new-trigger-name as xs:string
) as empty-sequence()
Summary: Changes the name of a trigger.
Parameters:
$trigger-name : The current trigger name.
$new-trigger-name : The new trigger name.
Usage Notes: Changes the name of a trigger from $trigger-name to $new-trigger-name. This function must be run in the context of the database containing the trigger whose name is to be changed. If no trigger trigger named $trigger-name exists, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: In the context of the database containing the trigger :)
    trgr:trigger-set-name("currentName", "newName")
trgr:trigger-set-permissions(
| $trigger-name as xs:string,
| $permissions as element(sec:permission)*
) as empty-sequence()
Summary: Sets the permissions that determine which roles are permitted to modify the named trigger.
Parameters:
$trigger-name : The trigger name.
$permissions : A sequence of permission nodes.
Usage Notes: Any permissions previously associated with the trigger are replaced. This function must be run in the context of the database containing the trigger to be modified. If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    (: Run in the context of the database containing the trigger :)
    trgr:trigger-set-permissions(
      "myTrigger",
      xdmp:default-permissions() )

      => Empty sequence. The trigger "myTrigger" may be modified
         roles which have the default permissions.
trgr:trigger-set-recursive(
| $trigger-name as xs:string,
| $recursive as xs:boolean
) as empty-sequence()
Summary: Sets the recursive setting of the identified trigger. When the recursive setting is true, the trigger will trigger itself for recursive changes to the same document.
Parameters:
$trigger-name : The current trigger name.
$recursive : The new recursive value for the specified trigger.
Usage Notes: If the named trigger does not exist, the exception `TRGR-TRIGGERDNE` is raised.
Example:
    xquery version "1.0-ml";
    import module namespace trgr="http://marklogic.com/xdmp/triggers"
       at "/MarkLogic/triggers.xqy";

    trgr:trigger-set-recursive("myTrigger", fn:true())

      => Empty sequence. Sets the named trigger to be recursive.

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.