Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created June 9, 2014 11:15
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 ableasdale/ab5dea6d883cc7a9c404 to your computer and use it in GitHub Desktop.
Save ableasdale/ab5dea6d883cc7a9c404 to your computer and use it in GitHub Desktop.
MD5 Checksum for document and all associated properties
xquery version "1.0-ml";
declare function local:get-document-collections-ordered($uri as xs:string) as xs:string {
for $i in xdmp:quote(xdmp:document-get-collections($uri))
order by $i
return $i
};
declare function local:calculate-md5-checksum($uri as xs:string) as xs:string {
xdmp:md5(fn:concat(
xdmp:quote(fn:doc($uri)),
xdmp:quote(xdmp:document-properties($uri)),
local:get-document-collections-ordered($uri)
))
};
(: Module main :)
for $x in cts:uris()
return
(
$x,
local:calculate-md5-checksum($x)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment