Created
August 28, 2015 18:29
-
-
Save CliffordAnderson/51904d6e2eab69702f73 to your computer and use it in GitHub Desktop.
Tricky Metadata Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
declare namespace marc="http://www.loc.gov/MARC21/slim"; | |
let $csv := element csv { | |
let $records := fn:doc("https://raw.githubusercontent.com/sterkenburgsara/MARCXML-projects/master/Artists'%20Books/artistsbk.xml")//marc:collection/marc:record | |
for $record in $records | |
let $leader := $record/marc:leader/text() | |
let $title := | |
($record//marc:datafield[@tag='245']//text() | |
except $record//marc:subfield[@code="c"]/text()) | |
=> fn:string-join(" ") | |
=> fn:replace("/$", "") | |
=> fn:normalize-space() | |
let $publoc := | |
let $control-8 := $record/marc:controlfield[@tag='008']/text() | |
let $publoc := fn:substring($control-8,16,3) | |
return $publoc | |
let $csv-record := | |
element record { | |
element leader {$leader}, | |
element title {$title}, | |
element publoc {$publoc} | |
} | |
where $publoc = ("alu", "aru", "dcu", "deu", "flu", "gau", "kyu", "lau", "mdu", "msu", "oku", "ncu", "scu", "tnu", "txu", "vau", "wvu", "xx ") | |
order by $publoc | |
return$csv-record | |
} | |
return csv:serialize($csv, map {'header':true()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment