Skip to content

Instantly share code, notes, and snippets.

@kschlottmann
Created May 12, 2021 21:46
Show Gist options
  • Save kschlottmann/7ef5dc5c502f1c15eebe1b31b5f603bf to your computer and use it in GitHub Desktop.
Save kschlottmann/7ef5dc5c502f1c15eebe1b31b5f603bf to your computer and use it in GitHub Desktop.
This xquery will match all records containing an arbitrary term, from the raw ArchivesSpace MARC output from the OAI feed
xquery version "3.0";
declare namespace marc="http://www.loc.gov/MARC21/slim";
(: This xquery will match all records containing an arbitrary term, from the raw ArchivesSpace MARC output from the OAI feed :)
<results>
{
for $MarcRecord in /repository/record/metadata/collection/record
for $word in ("alien", "Alien", "Aliens", "aliens")
where $MarcRecord/datafield/subfield[contains(., $word)]
let $rec := $MarcRecord
let $repo := $MarcRecord/datafield[@tag="040"]/subfield[@code="a"]
let $bib := $MarcRecord/datafield[@tag="099"]
let $fieldMatch := $MarcRecord/datafield[subfield[contains(., $word)]]
return
<result><bib>{data($bib)}</bib><repo>{data($repo)}</repo>{$fieldMatch} </result>
}
</results>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment