You want to disable or delete a template. In order to do so, it must be re-inserted in a disabled state with the same URI.
Applies to MarkLogic versions 9.0+
In order to disable templates in an XQuery Query Console:
$content-db
to the project’s Content database.$uris
to a sequence of URIs corresponding to the templates to be disabled.xquery version "1.0-ml"; import module namespace tde = "http://marklogic.com/xdmp/tde" at "/MarkLogic/tde.xqy"; let $content-db := "data-hub-FINAL" let $uris := ( "/tde/Template.xml" ) for $uri in $uris let $doc := fn:doc($uri) let $permissions := xdmp:document-get-permissions($uri) let $new-doc := document { element tde:template { element tde:enabled { fn:false() }, $doc/tde:template/node()[fn:node-name(.) ne xs:QName('tde:enabled')] } } return xdmp:invoke-function( function() { let $_ := tde:template-insert($uri, $new-doc, $permissions) return "'"||$uri||"' disabled" }, map:entry("database", xdmp:database($content-db)) )
Required Privileges:
tde-admin
rest-reader
This script iterates over the sequence of URIs. For each URI, get the template document and its permissions, build a new document with enabled set to false, and insert it into the content database with the same URI and permissions. Once re-indexing is complete, the template is safe to delete or leave in the schema database.
This script can also be used to enable disabled templates by changing the enabled element constructor to true, and changing the printed statement after insertion.
By continuing to use this website you are giving consent to cookies being used in accordance with the MarkLogic Privacy Statement.