Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 5, 2015 17:27
Show Gist options
  • Save caschwartz/2843975 to your computer and use it in GitHub Desktop.
Save caschwartz/2843975 to your computer and use it in GitHub Desktop.
Use cts:uris to query 730 fields for local collection headings in MARCXML
xquery version "1.0-ml";
(: 3/2/12 Use MarkLogic function cts:uris to query 730 fields for local collection headings in embedded MARCXML :)
declare namespace ia = "http://my.server/my.directory";
declare namespace m = "http://www.loc.gov/MARC21/slim";
let $values := fn:distinct-values(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 $collections := $marc/m:datafield[@tag = "730"][@ind2 = " "]
return for $collection in $collections
where fn:contains($collection, "collection")
or fn:contains($collection, "Collection")
or fn:contains($collection, "library")
or fn:contains($collection, "Library")
return fn:normalize-space(fn:replace($collection, "\.", "", "i")))
for $value in $values
order by $value
return $value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment