Skip to content

Instantly share code, notes, and snippets.

View caschwartz's full-sized avatar

Christine Schwartz caschwartz

View GitHub Profile
xquery version "1.0-ml";
(: 8/29/18 Query used to add three attributes: type, integer, and id to new <relatedNumber> element :)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
for $doc in collection("pts-journals")
let $vol-info := $doc/ia:doc/ia:metadata/ia:relatedItem/ia:volumeInfo
let $volume := $vol-info/ia:volume
@caschwartz
caschwartz / identify-duplicates.xqy
Last active May 19, 2017 15:38
Query McIntire audio recordings to identify duplicates based on recording date
xquery version "1.0-ml"; (: Delete/change XQuery version declaration if not a MarkLogic user :)
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
declare namespace ia = "http://digital.library.ptsem.edu/ia";
let $rec-dates :=
for $doc in collection("media-available")
let $title := $doc/ia:doc/ia:metadata/ia:title
let $rec-date := $doc/ia:doc/ia:metadata/ia:recordingDate
@caschwartz
caschwartz / get-copy-info.xqy
Created June 8, 2016 14:47
Function to get copy numbers from Ex Libris Voyager items record
(: Check for copy numbers in the items record :)
declare function mpm:get-copy-info($seq as xs:integer)
as node()*
{
let $records := xdmp:directory(concat("/Monographs/", $seq, "/"), "infinity")
let $items := $records/holdings/institution/holding/item (: May be more than one item record :)
for $item in $items
let $copy-info := $item/itemData[@name = "copy"]
return $copy-info
};
@caschwartz
caschwartz / locate-imported-books.xqy
Last active August 29, 2015 14:24
Query newly imported Benson collection books for volume information
xquery version "1.0-ml";
(: 12/5/13 Query newly imported Benson collection books for volume information :)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
<hits>{
for $doc in fn:collection("Benson")[1 to 1000]
let $title := fn:normalize-space($doc/ia:doc/ia:metadata/ia:title)
@caschwartz
caschwartz / remove-ds-store-files.xqy
Created April 8, 2015 14:07
Query to remove .DS_Store (and othe similar) files
xquery version "1.0-ml";
(: 12/20/14 Query to get a list of URIs from the dcweb database and delete .DS_Store files :)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
for $uri in cts:uris()
where contains($uri, "._.DS_Store") or contains($uri, ".DS_Store") or matches($uri, "\._")
@caschwartz
caschwartz / create-csv-file.xqy
Created March 10, 2015 18:03
Query to create a CSV file to import into Excel
xquery version "1.0-ml";
(:
: This main module queries basic Tanis postcards metadata for IA to create a
: CSV file to import into Excel. For Excel import, quotation marks are needed
: if value could contain a comma. Needed quotes for Title, Location, and Postcard-type.
:)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
declare namespace m = "http://www.loc.gov/mods/v3";
@caschwartz
caschwartz / find-editor-properties.xqy
Created February 19, 2015 18:53
Query to find properties concerning editor review dates for postcards project
xquery version "1.0-ml";
(: This query finds properties information :)
declare namespace ia = "http://my.namespace/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
for $doc in fn:collection()
let $property := fn:QName("", "metadata-editor-reviewed-by")
@caschwartz
caschwartz / replace-name-values.xqy
Created December 18, 2014 16:10
Normalize authors for Bollettino della Società di studi valdesi in Theological Commons to the society's currently used form of name
xquery version "1.0-ml";
(: 12/18/14 Normalize authors for Bollettino della Società di studi valdesi in Theological Commons to the society's currently used form of name :)
declare namespace ia = "http://digital.library.ptsem.edu/ia";
for $doc in xdmp:directory("/ia-xml/b/", "infinity")
let $name := $doc/ia:doc/ia:metadata/ia:name
where fn:contains($name, "Société d'histoire vaudoise")
@caschwartz
caschwartz / create-zip-files.xqy
Created December 10, 2014 16:31
Query to create zip files for the MODS documents in the dcweb database
xquery version "1.0-ml";
let $directory := "/theocom/"
let $uris := cts:uris("","document",cts:directory-query($directory,"infinity"))[70001 to 80000]
let $parts := (for $i in $uris let $x := fn:doc($i) return $x)
let $manifest := <parts xmlns="xdmp:zip">
{
for $i in $uris
@caschwartz
caschwartz / change-schema-location-attribute.xqy
Created October 9, 2014 16:33
Query accessions database to correct the location of the xml schema document for validation of accessions records
xquery version "1.0-ml";
(: 10/9/14 Query accessions database to correct the location of the xml schema document for validation :)
declare namespace arch = "http://www.inmagic.com/webpublisher/query";
for $doc in fn:collection()
let $oldAttributeNode := $doc/arch:Record/@xsi:schemaLocation
let $schemaLoc := $doc/arch:Record/@xsi:schemaLocation/fn:string()
where $schemaLoc