Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active December 18, 2015 23:28
Show Gist options
  • Save caschwartz/b12e4d6d10087c5cc3bd to your computer and use it in GitHub Desktop.
Save caschwartz/b12e4d6d10087c5cc3bd to your computer and use it in GitHub Desktop.
XQuery - Query theocom documents for edition for works by John Calvin
xquery version "1.0-ml";
(: 5/29/11 Query theocom documents for edition for works by John Calvin :)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
for $doc in xdmp:directory("/ia-xml/8/", "infinity")
let $marc := $doc/ia:doc/ia:metadata/ia:marc/m:record
let $name := $doc/ia:doc/ia:metadata/ia:name
let $sortTitle := $doc/ia:doc/ia:metadata/ia:sortTitle
let $edition := $marc/m:datafield[@tag = "250"]
let $newNodeEdition := <edition xmlns="http://digital.library.ptsem.edu/ia">{ fn:normalize-space($edition) }</edition>
let $newLine := text {"&#10;"}
let $indent := text {" "}
where $name = "Calvin, Jean, 1509-1564." and $edition
return let $empty := xdmp:node-insert-after($sortTitle, $newLine)
let $empty := xdmp:node-insert-after($sortTitle, $indent)
let $empty := xdmp:node-insert-after($sortTitle, $newNodeEdition)
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment