Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 25, 2016 18:49
Show Gist options
  • Save caschwartz/2845492 to your computer and use it in GitHub Desktop.
Save caschwartz/2845492 to your computer and use it in GitHub Desktop.
XQuery - Query to create sequential journal article ids
(: 11/23/11 Cliff's Code - Sequential Article ID's :)
xquery version "1.0-ml";
declare namespace mets = "http://www.loc.gov/METS/";
for $doc in xdmp:directory("/METS/")
let $dmdSecs :=
for $dmdSec in $doc/mets:mets/mets:dmdSec
where $dmdSec//*:type = "Article"
return $dmdSec
let $articles := fn:count($dmdSecs)
where fn:not(fn:contains(fn:base-uri($doc), "PSB"))
return
for $article in (1 to $articles)
return fn:concat(fn:base-uri($doc),$article)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment