Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 5, 2015 20:17
Show Gist options
  • Select an option

  • Save caschwartz/2869559 to your computer and use it in GitHub Desktop.

Select an option

Save caschwartz/2869559 to your computer and use it in GitHub Desktop.
Query retrieves multi-volume duplicate titles from both local schema metadata and MARCXML
xquery version "1.0-ml";
(: 6/4/12 This query retrieves multi-volume duplicate titles for the his directory :)
declare namespace ia = "http://my.server/my.directory";
declare namespace m = "http://www.loc.gov/MARC21/slim";
fn:distinct-values
(
let $docs := xdmp:directory("/ia-xml/h/hi/his/", "infinity")
for $doc in $docs
let $title := $doc/ia:doc/ia:metadata/ia:title
let $volumeInfo := $doc/ia:doc/ia:metadata/ia:marc/m:record/m:datafield[@tag = "300"]/m:subfield[@code = "a"]
where fn:not(fn:matches($volumeInfo, "^1 v.")) and fn:contains($volumeInfo, "v.") or fn:contains($volumeInfo, "vol.")
order by $title ascending
return fn:normalize-space($title)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment