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
<!-- | |
This is a sample data file for capturing coterminous appointments | |
Store in the /db/cms/apps/principals-chiefs/data/coterminous-appointments collection. | |
The rule for deriving the file's <id> (and file basename) is to join the following elements with a hyphen: | |
YYYY: the year of the first appointment | |
ABCD: the first four letters of the appointee's last name (unless fewer than 4 letters | |
NN: usually 01, but increment to 02, 03, etc. to prevent id collisions | |
In this example: | |
2012: all appointments started in 2012 | |
palm: from Palmer |
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 "3.1"; | |
(: parse tweets using XQuery 3.1's JSON support | |
: see http://www.w3.org/TR/xpath-functions-31/#json | |
: sample JSON from https://dev.twitter.com/rest/reference/get/statuses/user_timeline | |
:) | |
let $json := json-doc('/db/user_timeline.json') | |
let $tweets := $json?* | |
return |
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 "3.1"; | |
(:~ | |
: An implementation of XQuery 3.1's fn:json-to-xml and fn:xml-to-json functions for eXist, which does not support them natively as of 4.3.0. | |
: | |
: @author Joe Wicentowski | |
: @version 0.4 | |
: @see http://www.w3.org/TR/xpath-functions-31/#json | |
:) | |
module namespace jx = "http://joewiz.org/ns/xquery/json-xml"; |
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 "3.0"; | |
module namespace my-app = "http://my/app"; | |
(: A starter template for a RestXQ module. | |
Save this file into eXist anywhere (e.g., /db/restxq-template.xqm or /db/apps/my-app/modules/restxq-template.xqm), | |
And access at http://localhost:8080/exist/restxq/index.html. | |
(Why? Because /restxq is the URL space for RestXQ, and the function's %rest:path annotation is for requests to "/index.html".) | |
Note that the collection configuration file where you store the module must invoke the RestXQ trigger: | |
<collection xmlns="http://exist-db.org/collection-config/1.0"> |
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 "3.0"; | |
(: Transform volumes from the FRUS series (TEI XML) into a zip file containing JSON and text files | |
formatted for Bookworm http://bookworm.culturomics.org/. The resulting data can be accessed at: | |
http://static.history.state.gov/temp/frus-all.zip (140 MB) | |
A link to the running demo of the resulting data awaits fixes to the bookworm server, | |
but @bmschmidt kindly posted one volume's worth of data at | |
http://benschmidt.org/joewiz/ | |
:) |
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 "3.0"; | |
(: This sample library module contains a single function, iu:analyze-date-string(). | |
: The purpose of the sample is to demonstrate XQSuite tests, a unit test framework that uses | |
: XQuery 3.0's Annotations facility to embed testing assertions and parameters in XQuery functions. | |
: | |
: By writing unit tests and running them after each new change to an application, we can spot new bugs | |
: right away and prevent regressions. | |
: | |
: The XQSuite tests in this example are stored in a separate module, 02-tests-xql. |
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 "3.0"; | |
(: Displays a list of Principals & Chiefs whose positions ended after a certain date. :) | |
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; | |
declare option output:method "html5"; | |
declare option output:media-type "text/html"; | |
let $all-people := collection('/db/cms/apps/principals-chiefs/data/')/person | |
let $cut-off := '2008-06-01' |
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 "3.0"; | |
(: Displays a list of Principals & Chiefs hailing from Massachusetts. :) | |
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; | |
declare option output:method "html5"; | |
declare option output:media-type "text/html"; | |
let $all-people := collection('/db/cms/apps/principals-chiefs/data/')/person | |
let $state := 'ma' |
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 "3.0"; | |
(: Set the absolute file path appropriate for your OS :) | |
let $source-directory := | |
(: Mac :) | |
(: '/Users/Joe/workspace/myapp/data' :) | |
(: Windows :) | |
'C:\Users\wicentowskijc\workspace\myapp\data' | |
let $target-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 "3.0"; | |
declare function local:days-since-date($date as xs:date) { | |
let $duration := current-date() - $date | |
let $days := days-from-duration($duration) | |
return | |
$days | |
}; | |
local:days-since-date(xs:date('2012-10-12')) |