Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 5, 2015 17:28
Show Gist options
  • Save caschwartz/2844467 to your computer and use it in GitHub Desktop.
Save caschwartz/2844467 to your computer and use it in GitHub Desktop.
XQuery - Query to add TYPE attributes for incomplete items in METS documents
xquery version "1.0-ml";
(: 3/8/12 Query to add TYPE attributes for incomplete items in METS documents :)
declare namespace mets = "http://www.loc.gov/METS/";
let $doc := fn:doc("/METS/Kuyper128.xml")
let $seriesNum := "128" (: Series number for incomplete items :)
let $divs := $doc/mets:mets/mets:structMap//mets:div (: Will work with any div at any level in the hierarchy :)
for $div in $divs
where fn:substring($div/@ID, 7) = $seriesNum (: Substring is number without "Kuyper" :)
return if ($div/@TYPE) then
xdmp:node-replace($div/@TYPE, attribute TYPE { "suppress" })
else xdmp:node-insert-child($div, attribute TYPE { "suppress" })
xquery version "1.0-ml";
(: 3/8/12 Query to add TYPE attributes for incomplete items in the kuyper-dl database :)
declare namespace mets = "http://www.loc.gov/METS/";
let $doc := fn:doc("/METS/Kuyper128.xml")
let $seriesNum := "128" (: Cortney will provide series number for incomplete items :)
let $divs := $doc/mets:mets/mets:structMap//mets:div (: Will work with any div at any level in the hierarchy :)
for $div in $divs
where fn:substring($div/@ID, 7) = $seriesNum (: Substring is number without "Kuyper" :)
return if ($div/@TYPE) then
xdmp:node-replace($div/@TYPE, attribute TYPE { "suppress" })
else xdmp:node-insert-child($div, attribute TYPE { "suppress" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment