Skip to content

Instantly share code, notes, and snippets.

@CliffordAnderson
Last active December 19, 2015 22:08
Show Gist options
  • Save CliffordAnderson/6025035 to your computer and use it in GitHub Desktop.
Save CliffordAnderson/6025035 to your computer and use it in GitHub Desktop.
Simple example of requesting items from the SRU gateway at the Library of Congress
xquery version "3.0";
(: Look ups records at the Library of Congress in the specified metadata format :)
declare namespace mods = "http://www.loc.gov/mods/v3";
declare namespace dc = "http://purl.org/dc/elements/1.1/";
declare namespace marcxml = "http://www.loc.gov/MARC21/slim";
declare namespace zs = "http://www.loc.gov/zing/srw/";
(: change the lccn for different items :)
let $lccn := "2011005881"
(: change the requested format for different kinds of metadata - "dc", "marcxml", or "mods":)
let $metadata-format := "mods"
let $search := fn:concat("http://z3950.loc.gov:7090/voyager?operation=searchRetrieve&recordSchema=", $metadata-format, "&version=1.1&recordPacking=xml&query=bath.lccn=", $lccn, "&maximumRecords=1")
let $metadata := http:send-request(<http:request method='get' href="{$search}"/>)
return $metadata//zs:recordData/*
@CliffordAnderson
Copy link
Author

Copy and paste into BaseX. Try experimenting with different lccn's and metadata formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment