Created
October 29, 2019 13:46
-
-
Save prestonmcgowan/abb676402bb3ba1ee686e62576e218c8 to your computer and use it in GitHub Desktop.
Install valid TDE or show validation error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
import module namespace tde = "http://marklogic.com/xdmp/tde" | |
at "/MarkLogic/tde.xqy"; | |
let $template-uri := "/gds_sample_GeoJSON.tde" | |
let $template := | |
<template xmlns="http://marklogic.com/xdmp/tde"> | |
<description>Example template for GeoJSON documents</description> | |
<context>/envelope[header/type="geojson"]</context> | |
<collections> | |
<collection>example-geo</collection> | |
</collections> | |
<templates> | |
<template xmlns:tde="http://marklogic.com/xdmp/tde"> | |
<context>./instance</context> | |
<rows> | |
<row> | |
<schema-name>GDS_Sample</schema-name> | |
<view-name>GeoJSON</view-name> | |
<view-layout>sparse</view-layout> | |
<columns> | |
<column> | |
<name>OBJECTID</name> | |
<scalar-type>long</scalar-type> | |
<val>pointId</val> | |
</column> | |
<column> | |
<name>name</name> | |
<scalar-type>string</scalar-type> | |
<val>name</val> | |
<nullable>true</nullable> | |
</column> | |
</columns> | |
</row> | |
</rows> | |
</template> | |
</templates> | |
</template> | |
let $valid := tde:validate($template) | |
return | |
if (map:get($valid, "valid") eq fn:true()) then ( | |
"Template is valid, Inserting it into the schema database", | |
tde:template-insert($template-uri, $template) | |
) else | |
$valid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment