MarkLogic 9 Product Documentation
tde:template-insert

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

Summary

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.

Parameters
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.

Example

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>
  <context>/MedlineCitation/Article</context>
  <rows>
    <row>
      <schema-name>Medical</schema-name>
      <view-name>Publications</view-name>
      <columns>
        <column>
          <name>ID</name>
          <scalar-type>long</scalar-type>
          <val>../MedlineID</val>
        </column>
        <column>
          <name>ISSN</name>
          <scalar-type>string</scalar-type>
          <val>Journal/ISSN</val>
        </column>
      </columns>
    </row>
  </rows>
</template>

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

(: Inserts the template as the Template.xml file. :)
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy