Skip to content

Instantly share code, notes, and snippets.

@prestonmcgowan
Created October 10, 2019 18:49
Show Gist options
  • Save prestonmcgowan/1c3b1138c84cac8add80b1edbc77fd0c to your computer and use it in GitHub Desktop.
Save prestonmcgowan/1c3b1138c84cac8add80b1edbc77fd0c to your computer and use it in GitHub Desktop.
Patch MarkLogic Modules File
xquery version "1.0-ml";
let $uri := '/ext/lib/my-search-lib.xqy'
let $filename := "/var/opt/MarkLogic/Temp/my-search-lib.xqy"
let $code := xdmp:document-get($filename)
(: Uncomment the next line to verify the file is able to be read
return $code
:)
(: Using node-replace instead of insert-document causes all permissions and collections to be maintained. :)
return xdmp:node-replace(fn:doc($uri)/text(), text{ $code } )
;
(: Verify :)
let $uri := "/ext/lib/my-search-lib.xqy"
return fn:doc($uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment