Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 25, 2016 18:38
Show Gist options
  • Select an option

  • Save caschwartz/2845857 to your computer and use it in GitHub Desktop.

Select an option

Save caschwartz/2845857 to your computer and use it in GitHub Desktop.
XQuery - Query METS documents to normalize book title list
xquery version "1.0-ml";
(: 7/13/11 Working on browse book title list for Digital Library of AK :)
declare namespace METS = "http://www.loc.gov/METS/";
declare namespace dc = "http://purl.org/dc/elements/1.1/";
declare namespace html = "http://www.w3.org/1999/xhtml";
let $collection := fn:collection()
let $first-section := $collection/METS:mets/METS:dmdSec[1]
let $books := $first-section/METS:mdWrap/METS:xmlData[dc:type = "Book"]
for $title in $books/dc:title
(: order by fn:normalize-space(fn:replace($title,'(\(|\[|\"|The |An? |(\d. ?)|V?(I*)( |\.))*','')) :)
order by $title ascending
return fn:data($title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment