Skip to content

Instantly share code, notes, and snippets.

@joewiz
Last active December 22, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewiz/6525290 to your computer and use it in GitHub Desktop.
Save joewiz/6525290 to your computer and use it in GitHub Desktop.
Chiefs of Mission appointed during the presidency of Richard Nixon, using XQuery
xquery version "3.0";
let $roles := collection('/db/cms/apps/principals-chiefs/code-tables/roles/data')/role
let $countries := collection('/db/cms/apps/countries/data')/country
let $start-date := '1969-01-20'
let $end-date := '1974-08-09'
let $appointments := collection('/db/cms/apps/principals-chiefs/data')//event[@type='appointed' and @when gt $start-date and @when lt $end-date]/parent::role[@class='chief' and @type ne 'charge-daffaires-ad-interim']
return
<div>
<p>{count($appointments)} Chiefs of Mission who were appointed between {format-date(xs:date($start-date), "[MNn] [D], [Y]")} and {format-date(xs:date($end-date), "[MNn] [D], [Y]")}.</p>
<ol>{
for $appointment in $appointments
let $date := $appointment/event[@type='appointed']/@when
let $person := $appointment/parent::person
let $name := string-join(($person/persName/surname, $person/persName/forename, $person/persName/genName), ', ')
let $rolename := $roles[id = $appointment/@type]/names/singular/string()
let $dates :=
string-join(
for $date in $appointment/event[@type=('appointed', 'appointmentterminated', 'missionterminated')]/@when
return
if ($date castable as xs:date) then format-date(xs:date($date), "[MNn] [D], [Y]") else concat($date, ' (?)')
,
'–'
)
let $location := if ($appointment/@location) then concat(' to ', $countries[iso2 = $appointment/@location]/label) else ()
let $id := $person/@id
(:where contains($rolename, 'Ambassador'):)
order by lower-case($name)
return <li><a href="http://history.state.gov/departmenthistory/people/{$id}">{$name}</a> ({$rolename, $location}, {$dates})</li>
}</ol>
</div>
<div>
<p>268 Chiefs of Mission who were appointed between January 20, 1969 and August 9, 1974.</p>
<ol>
<li>
<a href="http://history.state.gov/departmenthistory/people/adair-charles-wallace">Adair, Charles Wallace, Jr.</a>
(Ambassador Extraordinary and Plenipotentiary to Uruguay, September 15, 1969–September 28, 1972)</li>
<li>
<a href="http://history.state.gov/departmenthistory/people/adair-edwin-ross">Adair, Edwin Ross</a>
(Ambassador Extraordinary and Plenipotentiary to Ethiopia, May 11, 1971–February 12, 1974)</li>
<li>
<a href="http://history.state.gov/departmenthistory/people/aggrey-orison-rudolph">Aggrey, Orison Rudolph</a>
(Ambassador Extraordinary and Plenipotentiary to Gambia, The, November 23, 1973–July 10, 1977)</li>
<li>
<a href="http://history.state.gov/departmenthistory/people/aggrey-orison-rudolph">Aggrey, Orison Rudolph</a>
(Ambassador Extraordinary and Plenipotentiary to Gambia, The, November 23, 1973–July 10, 1977)</li>
<!-- the rest -->
</ol>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment