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";
(: This query finds properties information :)
declare namespace ia = "http://my.namespace/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
let $docs := xdmp:directory("/ia-xml/1/", "infinity")
for $doc in $docs
@caschwartz
caschwartz / mets-add-type-attributes.xqy
Created April 7, 2014 19:16
XQuery - Query to add TYPE attributes for incomplete items
xquery version "1.0-ml";
(: 3/8/12 Query to add TYPE attributes for incomplete items in the kuyper-dl database :)
declare namespace mets = "http://www.loc.gov/METS/";
declare namespace dc = "http://purl.org/dc/elements/1.1/";
fn:distinct-values(
for $doc in fn:collection()
xquery version "1.0-ml";
(: 12/9/13 Query newly imported Benson collection books for names :)
declare namespace ia = "http://my.namespace/ia";
declare namespace m = "http://www.loc.gov/MARC21/slim";
for $doc in fn:collection("Benson")
let $name := fn:normalize-space($doc/ia:doc/ia:metadata/ia:name)
@caschwartz
caschwartz / build-number-sequence.xqy
Created May 8, 2014 14:52
XQuery - Build a sequence of numbers and count the number of items in the sequence
xquery version "1.0-ml";
(: 5/8/14 Build a sequence of numbers and count the number of items in the sequence :)
fn:count(let $unprocessedfootage := "10-17"
let $firstNum := xs:integer(fn:substring-before($unprocessedfootage, "-"))
let $lastNum := xs:integer(fn:substring-after($unprocessedfootage, "-"))
return for $box in ($firstNum to $lastNum)
return $box)
@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
@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 / 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 / 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 / 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 / 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, "\._")