This file contains hidden or 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 "3.1"; | |
| declare %updating function local:persist($db as xs:string, $doc as element()) as empty-sequence() | |
| { | |
| let $book := element book {$doc/*} | |
| let $key := $book//key/text() | |
| return db:replace($db, $key, $book) | |
| }; | |
| let $db := "books" |
This file contains hidden or 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 "3.1"; | |
| let $old-words := | |
| <stopwords> | |
| <word>the</word> | |
| <word>a</word> | |
| <word>in</word> | |
| <word>of</word> | |
| <word>as</word> | |
| </stopwords> |
This file contains hidden or 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 "3.1"; | |
| declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
| for $p in fn:collection("fleurs-du-mal")//tei:p/text() | |
| where $p contains text "fleurs" | |
| return $p |
This file contains hidden or 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
| module namespace page = 'http://library.vanderbilt.edu/dpla'; | |
| (: Just a quick example of searching the DPLA API | |
| and returning a simple webpage. :) | |
| declare | |
| %rest:path("dpla/{$search}") | |
| %rest:query-param("key", "{$key}") | |
| %output:method("html") | |
| function page:html($search as xs:string, $key as xs:string) |
This file contains hidden or 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
| See http://www.gbif.org/developer/summary for background. | |
| Find the single occurrence with identifier http://bioimages.vanderbilt.edu/vanderbilt/7-314#2002-06-14 | |
| http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Fvanderbilt%2F7-314%232002-06-14 | |
| Note: the occurrenceID is URLencoded. | |
| Find occurrences | |
| - with scientificName=Quercus%20macrocarpa (bur oak, note: space between genus and species is URLencoded as "%20") | |
| - with decimalLatitude between 35.81 and 36.45 | |
| - with decimalLongitude between -87.21 and -86.27 |
This file contains hidden or 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
| --reference implementation in Haskell | |
| qsort' :: (Ord a) => [a] -> [a] | |
| qsort' [] = [] | |
| qsort' (x:xs) = qsort' smaller ++ [x] ++ qsort' larger | |
| where larger = [a | a <- xs, a > x] | |
| smaller = [b | b <- xs, b <= x] | |
This file contains hidden or 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 "3.1"; | |
| declare namespace functx = "http://www.functx.com"; | |
| for $title in fn:collection("books")/record/Title | |
| let $string-fun := "fn:upper-case" | |
| return xquery:eval( | |
| "declare variable $title external;" || | |
| $string-fun || "($title)", | |
| map { 'title': $title } ) |
This file contains hidden or 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 "3.1"; | |
| (: Thanks to Tao You!! :) | |
| declare function local:get_facet ($books as element()*, $path as xs:string, $facet_type as xs:string ) as element()? | |
| { | |
| <facet type="{$facet_type}">{ | |
| for $book in $books | |
| let $fld := $book/*[name()=$path] | |
| group by $f := $fld |
This file contains hidden or 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
| <terms> | |
| <term> | |
| <path>date</path> | |
| <facet>date</facet> | |
| </term> | |
| </terms> |
This file contains hidden or 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 "3.1"; | |
| declare function local:get_facet ($books as element()*, $path as xs:string, $facet_type as xs:string ) as element()? | |
| { | |
| <facet type="{$facet_type}">{ | |
| for $book in $books | |
| let $fld := $book/*[name()=$path] | |
| group by $f := $fld | |
| order by $f descending | |
| return element {$facet_type} {attribute v {$f}, attribute number {fn:count($book)} } |