Skip to content

Instantly share code, notes, and snippets.

@caschwartz
Last active October 5, 2015 20:17
Show Gist options
  • Select an option

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

Select an option

Save caschwartz/2869587 to your computer and use it in GitHub Desktop.
Query adds identifiers to local metadata schema <volumeInfo> elements
xquery version "1.0-ml";
(: 5/31/12 This query adds identifiers to <volumeInfo> elements :)
declare namespace ia = "http://my.server/my.directory";
declare namespace m = "http://www.loc.gov/MARC21/slim";
let $docs := xdmp:directory("/ia-xml/f/", "infinity")
let $titles := $docs/ia:doc/ia:metadata/ia:title
for $title in $titles
let $id := $title/preceding-sibling::ia:id
let $volumeInfo := $title/following-sibling::ia:volumeInfo
where $volumeInfo
order by $title ascending
return xdmp:node-insert-child($volumeInfo, attribute id { fn:replace($id, "^(.*)(\d{2}.*)$", "$1") }))
@caschwartz
Copy link
Copy Markdown
Author

I need to work on this query some more. I need to get the id value from volume one of each set and use that value for each volume in the set.

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