Loading TOC...


   $uri as xs:string,
   $root as node(),
   [$permissions as item()*],
   [$collections as xs:string*]
) as empty-sequence


This function validates the template, inserts the template as a document into the tde collection of the schema database (if executed on the content database) with the default permissions, and reindexes the database.

Note that, when a template is inserted, only those document fragments affected by the template are re-indexed. For more information, see Validating and Inserting a Template in the Application Developer's Guide.

$uri The URI of the template document to be inserted.
$root The template document. The template document can be in either JSON or XML format.
$permissions Any permissions to set on the template document.
$collections One or more collections in which to insert the template document.

Usage Notes

The tde-admin role is required in order to insert a template into the schema database.

Note that, unlike the other tde functions, this is a library function that requires that you import the tde.xqy module.


xquery version "1.0-ml"; 
import module namespace tde = "http://marklogic.com/xdmp/tde" 
        at "/MarkLogic/tde.xqy";

let $template := 
<template xmlns="http://marklogic.com/xdmp/tde">
  <description>populates patients' data</description>

return tde:template-insert("Template.xml", $template)

(: Inserts the template as the Template.xml file. :)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • Hello I am using the qconsole to insert a template for a collection. The template shows up in the Schema related to the database but when I try a SQL query I get the following error SQL-TABLENOTFOUND: Unknown table: Table 'SchemaName.ViewName' not found I'm not sure why this is happening any help would be appreciated
    • same issue with me. were you able to fix this?
    • Hi Alex. Can you please ask this on <a href="https://stackoverflow.com/questions/tagged/marklogic">Stack Overflow</a> so that it can reach a wider audience?
  • Hi, I created template and accessed template data using sql without any problem. My concern is to convert sql result ( which comes from template) into excel or pdf or html format . is it possible? if yes then please suggest me any link or any sample example.
  • I got the following error when executing the code in the query console: [1.0-ml] SVC-FILOPN: File open error: open '/MarkLogic/tde.xqy': No such file or directory Stack Trace At line 2 column 0: In xdmp:eval("xquery version &quot;1.0-ml&quot;; &#10;import module namespace ...", (), <options xmlns="xdmp:eval"><database>18182129315596444747</database>...</options>) 1. xquery version "1.0-ml"; 2. import module namespace tde = "http://marklogic.com/xdmp/tde" 3. at "/MarkLogic/tde.xqy"; Can you help me? Many Thanks Erik
    • Hi Erik. Please check your MarkLogic version number -- are you running 9.0-1.1?