Forked from AdamSteffanick/01-return-JSON-from-Open-Library.xquery
Last active
January 11, 2018 02:50
-
-
Save joewiz/a5bae0eced6f788fb49e34f264c765f7 to your computer and use it in GitHub Desktop.
Open Library
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"; | |
let $uri := "http://openlibrary.org/search.json?title=digital+humanities" | |
let $json := fetch:text($uri) | |
return $json |
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"; | |
let $uri := "http://openlibrary.org/search.json?title=digital+humanities" | |
let $json := fetch:text($uri) | |
let $xml := fn:json-to-xml($json) | |
return $xml |
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 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 |
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 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 |
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 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 |
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 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 |
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 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