Last active
October 11, 2015 13:47
-
-
Save caschwartz/3867861 to your computer and use it in GitHub Desktop.
Query two databases, compare URIs, and delete obsolete documents
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"; | |
| let $query := 'cts:uris()' | |
| let $options := | |
| <options xmlns="xdmp:eval"> | |
| <database>{ xdmp:database("my.database") }</database> | |
| </options> | |
| let $theocomURIs := xdmp:eval($query, (), $options) | |
| let $dcwebURIs := cts:uris("/theocom/ia-xml/")[70001 to 80000] | |
| for $dcwebURI in $dcwebURIs | |
| let $uriString := fn:replace($dcwebURI, "/theocom", "") | |
| return | |
| (: The obsolete documents will not match any of the $theocomURIs. :) | |
| if ($uriString = $theocomURIs) then | |
| () | |
| else if (fn:ends-with($uriString, ".xml")) then | |
| xdmp:document-delete(fn:concat("/theocom", $uriString)) | |
| else () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment