MarkLogic Server 11.0 Product Documentation
tde:template-batch-insert

tde:template-batch-insert(
   $template-infos as map:map*
) as empty-sequence()

Summary

This function validates and inserts multiple templates, is similar to tde:template-insert for individual template, throw errors for any invalid template or duplicate template URIs provided by sequence of argument with tde:template-info .

Before inserting, validates each new template against all other new and existing (not in the new URIs list) templates with same schema/view-name. Any existing template with the same URI in the new URIs list will be ignored and replaced directly even if the new template has same URI but different schema/view-name.

Parameters
template-infos A sequence of maps that specify the template information (URI, template, permissions, collections) to apply as produced by tde:template-info .

Usage Notes

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

Note that this is a library function that requires that you import the tde.xqy module.

Example

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

let $t1 := 
<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-batch-insert(
         ( tde:template-info("t1.xml",$t1),
           tde:template-info("t2.xml",xdmp:document-get("/temp/t2.xml")),
           tde:template-info("t3.xml",xdmp:document-get("/temp/t3.xml"),
             (xdmp:permission("role1","update"),
              xdmp:permission("role2","read")
             ),
             ("collectionA")
           )
         )
       )

(: Inserts 3 templates as t1.xml, t2.xml, t3.xml files. :)
Powered by MarkLogic Server | Terms of Use | Privacy Policy