Created
July 13, 2015 14:07
-
-
Save EdWarga/f206d6bb9c41dc9957fa to your computer and use it in GitHub Desktop.
XQ to harvest OAI-PMH records $verb=ListRecords
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.0"; | |
declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance"; | |
declare namespace oai = "http://www.openarchives.org/OAI/2.0/"; | |
declare namespace oai_dc = "http://www.openarchives.org/OAI/2.0/oai_dc/"; | |
declare namespace qdc = "http://purl.org/dc/terms/"; | |
declare function local:resume($base-url as xs:string, $token as xs:string) as document-node() | |
{ | |
let $doc := fn:doc(($base-url || "?verb=ListRecords&resumptionToken=" || $token)) | |
return | |
if ($doc//oai:resumptionToken = "") then ($doc, "LAST_RESPONSE.xml") | |
else (($doc, $doc//oai:resumptionToken/text()||".xml"), local:resume($base-url, $doc//oai:resumptionToken/text())) | |
}; | |
let $base-url := "http://dash.harvard.edu/oai/request" | |
let $set-spec := "hdl_1_3345929"(:business stuff:) | |
let $request := fn:string-join(($base-url,"?verb=ListRecords&metadataPrefix=oai_dc&set=",$set-spec), '') | |
let $initial-response := doc($request) | |
return | |
local:resume($base-url, $initial-response//oai:resumptionToken/text()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment