Skip to content

Instantly share code, notes, and snippets.

@nishantsingh1
Last active April 26, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishantsingh1/aceae68726e5a20339cb0c55c8edfa56 to your computer and use it in GitHub Desktop.
Save nishantsingh1/aceae68726e5a20339cb0c55c8edfa56 to your computer and use it in GitHub Desktop.
TriggerExample: Shared Library module with a common function
xquery version '1.0-ml';
(: common util module :)
xdmp:document-insert("/SAMPLE/MODULE/sample-library.xqy",
text{ '
xquery version "1.0-ml";
module namespace minilibrary = "minilib";
declare variable $dnamespace := "http://www.sample.net/schema/datahub";
declare function get-metadata() as node() {
let $isoFormat := "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01][Z]"
let $currentTS := current-dateTime()
let $currentISO := format-dateTime($currentTS, $isoFormat)
let $metadataCreated := element{QName($dnamespace, "createdTS") } {$currentISO}
return $metadataCreated
};'
}, xdmp:permission('app-user', 'execute'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment