Last active
March 3, 2017 15:35
-
-
Save joewiz/7cdd26c33b10ebd09f2f25751de4fbbe to your computer and use it in GitHub Desktop.
Generate a FRUS production status report, using XQuery
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"; | |
let $vols-in-production := collection('/db/apps/frus/bibliography')/volume[not(publication-status = ('published', 'being-planned-research-not-yet-begun'))] | |
let $admins := doc('/db/apps/frus/code-tables/administration-code-table.xml')//item | |
let $groupings := doc('/db/apps/frus/code-tables/grouping-code-table.xml')//item | |
let $statuses := doc('/db/apps/frus/code-tables/publication-status-codes.xml')//item | |
let $admin-years := | |
map { | |
"truman": "1945–1953", | |
"eisenhower": "1953–1961", | |
"kennedy": "1961–1963", | |
"johnson": "1964–1968", | |
"nixon-ford": "1969–1976", | |
"carter": "1977–1981", | |
"reagan": "1981–1989", | |
"bush-41": "1989–1993" | |
} | |
return | |
<production-status> | |
<date>{format-date(current-date(), '[MNn] [D], [Y0001]', 'en', (), 'US')}</date> | |
<publication-status-legend> | |
{ | |
for $status at $n in $statuses | |
return | |
<status n="{$n}">{$status/label/string()}</status> | |
} | |
</publication-status-legend> | |
{ | |
for $vol-g in $vols-in-production | |
group by $grouping := $vol-g/grouping | |
let $grouping-label := $groupings[value eq $grouping]/label | |
return | |
<group> | |
<label>{$grouping-label || " Volumes"}</label> | |
{ | |
for $vol-a in $vol-g | |
group by $admin := tokenize($vol-a/grouping/@administration, '\s+') | |
let $admin-label := $admins[value = $admin]/label || " (" || $admin-years($admin) || ")" | |
order by min(index-of($admins/value, $admin)) | |
return | |
<admin> | |
<label>{$admin-label}</label> | |
{ | |
for $vol in $vol-a | |
let $title := $vol/title[@type='volume'] | |
let $status := $vol/publication-status | |
let $status-numeric := index-of($statuses/value, $status) | |
let $status-label := $statuses[value eq $status]/label | |
order by $title | |
return | |
<vol id="{$vol/@id}"> | |
<title>{$title/string()}</title> | |
<status n="{$status-numeric}">{$status-label/string()}</status> | |
</vol> | |
} | |
</admin> | |
} | |
</group> | |
} | |
</production-status> |
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
<production-status> | |
<date>March 3, 2017</date> | |
<publication-status-legend> | |
<status n="1">Being Planned (research has not begun)</status> | |
<status n="2">Being Researched or Prepared</status> | |
<status n="3">Under Declassification Review</status> | |
<status n="4">In Production</status> | |
<status n="5">Published</status> | |
</publication-status-legend> | |
<group> | |
<label>Retrospective Volumes</label> | |
<admin> | |
<label>Truman (1945–1953)</label> | |
<vol id="frus1951-54Iran"> | |
<title>Iran, 1951–1954</title> | |
<status n="4">In Production</status> | |
</vol> | |
</admin> | |
</group> | |
<group> | |
<label>Regular Volumes</label> | |
<admin> | |
<label>Eisenhower (1953–1961)</label> | |
<vol id="frus1956-60IntelCom"> | |
<title>The Intelligence Community</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
</admin> | |
<admin> | |
<label>Nixon-Ford (1969–1976)</label> | |
<vol id="frus1969-76ve09p2"> | |
<title>Documents on the Middle East Region, 1973–1976</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1969-76v19p2"> | |
<title>Japan, 1969–1972</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1969-76v42"> | |
<title>The Kissinger-Le Duc Tho Negotiations</title> | |
<status n="4">In Production</status> | |
</vol> | |
</admin> | |
<admin> | |
<label>Carter (1977–1981)</label> | |
<vol id="frus1977-80v12"> | |
<title>Afghanistan</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v15"> | |
<title>Central America</title> | |
<status n="4">In Production</status> | |
</vol> | |
<vol id="frus1977-80v05"> | |
<title>European Security, 1977–1983</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1977-80v25"> | |
<title>Global Issues; United Nations Issues</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v11"> | |
<title>Iran: Hostage Crisis, November 1979-January 1981</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v10"> | |
<title>Iran: Revolution, January 1977–November 1979</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v14"> | |
<title>Korea; Japan</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1977-80v04"> | |
<title>National Security Policy</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v17p3"> | |
<title>North Africa</title> | |
<status n="4">In Production</status> | |
</vol> | |
<vol id="frus1977-80v07"> | |
<title>Poland, 1977–1981</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v24"> | |
<title>South America; Latin America Region</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1977-80v19"> | |
<title>South Asia</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v22"> | |
<title>Southeast Asia and the Pacific</title> | |
<status n="4">In Production</status> | |
</vol> | |
<vol id="frus1977-80v17p2"> | |
<title>Sub-Saharan Africa</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1977-80v27"> | |
<title>Western Europe</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
</admin> | |
<admin> | |
<label>Reagan (1981–1989)</label> | |
<vol id="frus1981-88v34"> | |
<title>Afghanistan, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v35"> | |
<title>Afghanistan, 1985–1989</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v19"> | |
<title>Arab-Israeli Dispute</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v14"> | |
<title>Central America, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v15"> | |
<title>Central America, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v28"> | |
<title>China, 1981–1983</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v29"> | |
<title>China, 1984–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v17p2"> | |
<title>Eastern Caribbean, 1981-1988</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v10"> | |
<title>Eastern Europe</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v45"> | |
<title>Eastern Mediterranean, 1981–1992</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v01"> | |
<title>Foundations of Foreign Policy</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v40"> | |
<title>Global Issues I</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v41"> | |
<title>Global Issues II</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v12"> | |
<title>INF, 1984–1987</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v42"> | |
<title>Immigration and Refugees, 1975–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v23"> | |
<title>Iran-Contra Affair, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v21"> | |
<title>Iran; Iraq, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v20"> | |
<title>Iran; Iraq, April 1980–January 1985</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v30"> | |
<title>Japan; Korea, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v31"> | |
<title>Japan; Korea, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v18p1"> | |
<title>Lebanon, April 1981–August 1982</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v18p2"> | |
<title>Lebanon, September 1982–March 1984</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v48"> | |
<title>Libya; Chad</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v17p1"> | |
<title>Mexico; Western Caribbean, 1981-1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v22"> | |
<title>Middle East Region; Arabian Peninsula</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v43"> | |
<title>National Security Policy, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v44"> | |
<title>National Security Policy, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v24"> | |
<title>North Africa</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v38"> | |
<title>North-South Relations; Commodity Policy</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v09"> | |
<title>Poland, 1982–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v39"> | |
<title>Public Diplomacy</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v11"> | |
<title>START I</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v16"> | |
<title>South America; Latin America Region</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v33"> | |
<title>South Asia</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v32"> | |
<title>Southeast Asia; Pacific</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v25"> | |
<title>Southern Africa, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v04"> | |
<title>Soviet Union, January 1983–March 1985</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v05"> | |
<title>Soviet Union, March 1985–October 1986</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v27"> | |
<title>Sub-Saharan Africa</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v47p1"> | |
<title>Terrorism, January 1981–May 1985</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v47p2"> | |
<title>Terrorism, June 1985–January 1989</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
<vol id="frus1981-88v36"> | |
<title>Trade; Monetary Policy; Industrialized Country | |
Cooperation, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v37"> | |
<title>Trade; Monetary Policy; Industrialized Country | |
Cooperation, 1985–1988 </title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v46"> | |
<title>War on Drugs</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v07"> | |
<title>Western Europe, 1981–1984</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1981-88v08"> | |
<title>Western Europe, 1985–1988</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
</admin> | |
<admin> | |
<label>Bush (1989–1993)</label> | |
<vol id="frus1989-92v09"> | |
<title>Germany</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1989-92v11"> | |
<title>Persian Gulf Crisis, 1989–1991</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1989-92v12"> | |
<title>Persian Gulf Crisis, 1991</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1989-92v13"> | |
<title>Persian Gulf Crisis, 1991–1992</title> | |
<status n="2">Being Researched or Prepared</status> | |
</vol> | |
<vol id="frus1989-92v31"> | |
<title>START</title> | |
<status n="3">Under Declassification Review</status> | |
</vol> | |
</admin> | |
</group> | |
</production-status> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment