Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewiz/a5bae0eced6f788fb49e34f264c765f7 to your computer and use it in GitHub Desktop.
Save joewiz/a5bae0eced6f788fb49e34f264c765f7 to your computer and use it in GitHub Desktop.
Open Library
xquery version "3.1";
let $uri := "http://openlibrary.org/search.json?title=digital+humanities"
let $json := fetch:text($uri)
return $json
xquery version "3.1";
let $uri := "http://openlibrary.org/search.json?title=digital+humanities"
let $json := fetch:text($uri)
let $xml := fn:json-to-xml($json)
return $xml
xquery version "3.1";
declare namespace xf = "http://www.w3.org/2005/xpath-functions";
let $uri := "http://openlibrary.org/search.json?title=digital+humanities"
let $json := fetch:text($uri)
let $xml := fn:json-to-xml($json)
let $isbns :=
for $isbn in $xml//xf:array[@key="isbn"]/xf:string/text()
return element isbn {$isbn}
return $isbns
xquery version "3.1";
declare namespace xf = "http://www.w3.org/2005/xpath-functions";
declare function local:get-isbn-by-title($book-title as xs:string) as element()* {
let $url := "http://openlibrary.org/search.json?title=" || fn:translate($book-title, " ", "+")
let $json := fetch:text($url)
let $isbn-data := fn:json-to-xml($json)
for $isbn in $isbn-data//xf:array[@key="isbn"]/xf:string/text()
return element isbn {$isbn}
};
let $book := "Digital Humanities"
let $isbns := local:get-isbn-by-title($book)
return $isbns
xquery version "3.1";
declare function local:get-volume-by-isbn($isbn as xs:string) as element()* {
let $url := "http://openlibrary.org/api/volumes/brief/isbn/" || $isbn || ".json"
let $json := fetch:text($url)
let $volume-data := fn:json-to-xml($json)
for $volume in $volume-data
return element volume {$volume}
};
let $isbn := "0262018470"
let $volume := local:get-volume-by-isbn($isbn)
return $volume
xquery version "3.1";
declare namespace xf = "http://www.w3.org/2005/xpath-functions";
declare function local:get-isbn-by-title($book-title as xs:string) as element()* {
let $url := "http://openlibrary.org/search.json?title=" || fn:translate($book-title, " ", "+")
let $json := fetch:text($url)
let $isbn-data := fn:json-to-xml($json)
for $isbn in $isbn-data//xf:array[@key="isbn"]/xf:string/text()
return element isbn {$isbn}
};
declare function local:get-volume-by-isbn($isbn as xs:string) as element()* {
let $url := "http://openlibrary.org/api/volumes/brief/isbn/" || $isbn || ".json"
let $json := fetch:text($url)
let $volume-data := fn:json-to-xml($json)
for $volume in $volume-data
return element volume {$volume}
};
let $book := "Digital Humanities"
let $records := local:get-isbn-by-title($book)
let $volumes :=
for $record in $records
return local:get-volume-by-isbn($record)
return $volumes
xquery version "3.1";
declare namespace xf = "http://www.w3.org/2005/xpath-functions";
declare function local:get-isbn-by-title($book-title as xs:string) as element()* {
let $url := "http://openlibrary.org/search.json?title=" || fn:translate($book-title, " ", "+")
let $json := fetch:text($url)
let $isbn-data := fn:json-to-xml($json)
for $isbn in $isbn-data//xf:array[@key="isbn"]/xf:string/text()
return element isbn {$isbn}
};
declare function local:get-recorduri-by-isbn($isbn as xs:string) as element()* {
let $url := "http://openlibrary.org/api/volumes/brief/isbn/" || $isbn || ".json"
let $json := fetch:text($url)
let $volume-data := fn:json-to-xml($json)
for $record-uri in $volume-data//xf:string[@key="recordURL"]/text()
return element record_uri {$record-uri}
};
let $book := "Digital Humanities"
let $records := local:get-isbn-by-title($book)
let $uris :=
for $record in $records
return local:get-recorduri-by-isbn($record)
return $uris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment