Last active
November 23, 2015 14:18
-
-
Save ableasdale/d0a96852869015d54b83 to your computer and use it in GitHub Desktop.
Parse a support dump, extract a single database (by name), remove all associated forest data and return the database element :)
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"; | |
(: | |
: Parse a support dump, extract a single database (by name), remove all associated forest data and return the database element | |
:) | |
declare namespace db="http://marklogic.com/xdmp/database"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
import module namespace mem = "http://xqdev.com/in-mem-update" at "/MarkLogic/appservices/utils/in-mem-update.xqy"; | |
(: Modify these two values | |
: - Support dump filepath : the path to the support dump on disk | |
: - Database name : the name of the database you want to extract | |
:) | |
declare variable $SUPPORT-DUMP-FILEPATH as xs:string := 'C:\Users\ableasdale\Downloads\support-request-go (1).txt'; | |
declare variable $DATABASE-NAME as xs:string := "SP-ML-Database"; | |
declare variable $support as document-node()* := xdmp:document-get( | |
$SUPPORT-DUMP-FILEPATH, | |
<options xmlns="xdmp:document-get"> | |
<format>xml</format> | |
<repair>full</repair> | |
</options> | |
); | |
let $node := mem:node-replace($support//db:databases/db:database[db:database-name eq $DATABASE-NAME]/db:forests, <db:forests/>) | |
return | |
<root xmlns="http://marklogic.com/xdmp/database" xmlns:db="http://marklogic.com/xdmp/database"> | |
{$node//db:databases/db:database[db:database-name eq $DATABASE-NAME]} | |
</root> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment