Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 25, 2016 18:46
Show Gist options
  • Save caschwartz/2844359 to your computer and use it in GitHub Desktop.
Save caschwartz/2844359 to your computer and use it in GitHub Desktop.
XQuery - Use cts:uris to find irregular call numbers in 090 fields in embedded MARCXML
xquery version "1.0-ml";
(: 2/23/11 Use MarkLogic function cts:uris to find irregular call numbers in the 090 field of MARCXML :)
declare namespace ia = "http://my.server/my.directory";
declare namespace m = "http://www.loc.gov/MARC21/slim";
let $uris := cts:uris((), "ascending")
for $uri in $uris[fn:position() = (50001 to fn:last())]
return for $doc in fn:doc($uri)
let $marc := $doc/ia:doc/ia:metadata/ia:marc/m:record
let $marcCode := $marc/m:datafield[@tag = "040"]/m:subfield[@code = "a"]
let $callNums := $marc/m:datafield[@tag = "090"]
let $callNumInd := $callNums[@ind2 = "9"]
for $callNum in $callNums
where $marcCode = "OTU" and $callNumInd
return $callNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment