Last active
October 25, 2016 18:44
-
-
Save caschwartz/2764025 to your computer and use it in GitHub Desktop.
XQuery - Adds "sort" element to dmdSec of METS documents for journal issue numbers
This file contains 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"; | |
(: 12/1/11 Adds "sort" element to dmdSec of METS documents for issue numbers :) | |
declare namespace sort = "http://my.server/my.directory"; | |
declare namespace mets = "http://www.loc.gov/METS/"; | |
declare namespace dc = "http://purl.org/dc/elements/1.1/"; | |
for $journal in xdmp:directory("/METS/")/mets:mets/mets:dmdSec[2]/mets:mdWrap/mets:xmlData | |
let $title := $journal/dc:format | |
let $issue := fn:replace(fn:normalize-space($title), "^The Princeton Seminary Bulletin Supplementary Issue No.\s(\d).*$", "$1") | |
let $sortIssue := element sort:issue {$issue} | |
let $sortIss := $journal/preceding::mets:dmdSec/mets:mdWrap/mets:xmlData/sort:issue | |
let $node := $journal/preceding::mets:dmdSec/mets:mdWrap/mets:xmlData | |
where fn:not($sortIss) and fn:matches($title, "^The Princeton Seminary Bulletin Supplementary Issue No.\s(\d).*$") | |
return | |
(: and fn:matches($title, "^.*\s(\d{1,2})$") :) | |
(: return xdmp:node-insert-child($node, $sortIssue) :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment