Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active December 28, 2015 08:19
Show Gist options
  • Select an option

  • Save caschwartz/7470252 to your computer and use it in GitHub Desktop.

Select an option

Save caschwartz/7470252 to your computer and use it in GitHub Desktop.
XQuery - Query to locate and comment out the empty MODS titleInfo elements using MarkLogic xdmp:node-replace()
xquery version "1.0-ml";
(: 11/13/13 Query to locate and comment out empty MODS titleInfo elements :)
declare namespace mods = "http://www.loc.gov/mods/v3";
for $doc in xdmp:directory("/MODS/", "infinity")
let $titles := $doc/mods:modsCollection/mods:mods/mods:titleInfo
for $title in $titles
return if (fn:normalize-space($title) = "") then
xdmp:node-replace($title, comment{ xdmp:quote($title) })
else ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment