-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add xquery and BaseX command script(s).
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare namespace oai = "http://www.openarchives.org/OAI/2.0/"; | ||
|
||
|
||
for $set in fn:doc('http://dpla.lib.utk.edu/repox/OAIHandler?verb=ListSets')/oai:OAI-PMH/oai:ListSets/oai:set | ||
let $spec := $set/oai:setSpec/text() | ||
let $name := $set/oai:setName/text() | ||
return( | ||
db:add('repox-sets', <set><spec>{$spec}</spec><name>{$name}</name></set>, $name) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(: preface this with a COMMAND: `set addcache true; create db OAI` :) | ||
(: grab oai-pmh from repox :) | ||
declare namespace oai = "http://www.openarchives.org/OAI/2.0/"; | ||
|
||
(: Retrieves metadata records for an entire OAI-PMH collection :) | ||
(: Adds records to BaseX database:) | ||
|
||
declare function local:request($base-url as xs:string, $verb as xs:string, $set-spec as xs:string) as document-node()* | ||
{ | ||
let $request := $base-url || $verb || $set-spec | ||
let $response := fn:doc($request) | ||
let $token := $response//oai:resumptionToken/text() | ||
return | ||
if (fn:empty($token)) then | ||
$response | ||
else | ||
($response, | ||
local:resume($base-url, $token)) | ||
}; | ||
|
||
declare function local:resume($base-url as xs:string, $token as xs:string) as document-node()* | ||
{ | ||
let $verb := "?verb=ListRecords&resumptionToken=" | ||
let $request := $base-url || $verb || $token | ||
let $response := fn:doc($request) | ||
let $new-token := $response//oai:resumptionToken/text() | ||
return | ||
if (fn:empty($new-token)) then | ||
$response | ||
else | ||
($response, | ||
local:resume($base-url, $new-token)) | ||
}; | ||
|
||
for $set in db:open('repox-sets')/set/spec/text() | ||
let $base-url := "http://dpla.lib.utk.edu/repox/OAIHandler" (: UTK's REPOX install :) | ||
let $verb := "?verb=ListRecords&metadataPrefix=oai_dc" | ||
let $set-spec := "&set=" || $set | ||
let $response := local:request($base-url, $verb, $set-spec) | ||
for $record in $response//oai:record | ||
let $id := $record/oai:header/oai:identifier/text() | ||
return( | ||
db:add(($set), $record, $id, map { 'addcache': true() } ) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(: this xquery script :) | ||
|
||
for $set in db:open('repox-sets')/set/spec/text() | ||
return | ||
db:create(($set), (), (), map { 'textindex': true(), 'attrindex': true(), 'tokenindex': true(), 'ftindex': true() } ) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- create a 'repox-sets' database --> | ||
|
||
<commands> | ||
<create-db name="repox-sets"/> | ||
</commands> |