Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 5, 2015 01:17
Show Gist options
  • Save caschwartz/2730607 to your computer and use it in GitHub Desktop.
Save caschwartz/2730607 to your computer and use it in GitHub Desktop.
XQuery - Query to replace ORDER attribute numbers in METS documents
xquery version "1.0-ml";
(: 1/26/12 Query to replace ORDER attribute numbers for third-level divs in structMap :)
declare namespace mets = "http://www.loc.gov/METS/";
declare namespace dc = "http://purl.org/dc/elements/1.1/";
let $divsNumTwo := let $doc := fn:doc("/new-divs/Kuyper365-370.xml")
let $structMap := $doc/mets:mets/mets:structMap
let $levelTwoDivs := $structMap/mets:div/mets:div
return for $levelTwoDiv in $levelTwoDivs
where $levelTwoDiv/mets:div/mets:div
return $levelTwoDiv
return for $divNumTwo in $divsNumTwo
let $divsNumThree := $divNumTwo/mets:div
return for $divNumThree at $count in $divsNumThree
return
(: xdmp:node-replace($divNumThree/@ORDER, attribute ORDER { $count }) :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment