This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: FizzBuzz puzzle :) | |
for $num in (1 to 100) | |
return | |
if ($num mod 3 = 0 and $num mod 5 = 0) then | |
"FizzBuzz" | |
else if ($num mod 3 = 0) then | |
"Fizz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: 1/6/14 Using Priscilla Walmsley's function, this query puts the root node and all descendant elements in the MARCXML namespace :) | |
declare namespace m = "http://www.loc.gov/MARC21/slim"; | |
declare namespace functx = "http://www.functx.com"; | |
declare function functx:change-element-ns-deep | |
( $nodes as node()* , | |
$newns as xs:string , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: Fix capitalization of collection titles ("inventory" database) :) | |
declare namespace mods = "http://www.loc.gov/mods/v3"; | |
fn:distinct-values( | |
for $doc in fn:collection("MODS") | |
let $collection-title := $doc/mods:modsCollection/mods:mods/mods:titleInfo[@type="uniform"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: 11/6/13 Query to create title list of (one volume) monographs with edition statements (using one of Priscilla Walmsley's functx XQuery functions :) | |
declare namespace ia = "http://my.local.namespace"; | |
declare namespace m = "http://www.loc.gov/MARC21/slim"; | |
declare namespace functx = "http://www.functx.com"; | |
declare function functx:non-distinct-values | |
( $seq as xs:anyAtomicType* ) as xs:anyAtomicType* { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: 11/4/13 Query to isolate the superscript numbers and change to ASCII numbers in the <tei:hi> element :) | |
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
for $doc in fn:collection() | |
let $superNums := $doc//tei:hi[@rend = "super"] | |
for $superNum in $superNums |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
(: 11/13/13 Query to locate and comment out empty MODS titleInfo elements :) | |
declare namespace mods = "http://www.loc.gov/mods/v3"; | |
for $doc in xdmp:directory("/MODS/", "infinity") | |
let $titles := $doc/mods:modsCollection/mods:mods/mods:titleInfo | |
for $title in $titles |