joewiz
7/30/2013 - 4:07 PM

Principal Officers who were serving on, or began service after, January 20, 1977, and who are still alive; using XQuery

Principal Officers who were serving on, or began service after, January 20, 1977, and who are still alive; using XQuery

<div>
    <h1>Principal Officers since the Carter Adminstration</h1>
    <h2>July 30, 2013</h2>
    <p>Principal Officers who were serving on, or began service after, January 20, 1977, and who are still alive. There are 343 entries. Note: Only terms of service as Principal Officer are shown; terms of service as Chief of Mission are not shown. Also, we do our best to monitor obituaries, but some people listed below may in fact have passed away. Please let us know if you discover any information that is out of date..</p>
    <ol>
        <li>
            <a href="http://history.state.gov/departmenthistory/people/abramowitz-morton-isaac">Abramowitz, Morton Isaac</a>
            (Foreign Service officer, b. 1933): Assistant Secretary of State for Intelligence and Research, February 1, 1985–May 19, 1989; Career Ambassador, November 21, 1989–.</li>
        <li>
            <a href="http://history.state.gov/departmenthistory/people/abrams-elliott">Abrams, Elliott</a>
            (Non-career appointee, b. 1948): Assistant Secretary of State for International Organization Affairs, May 7, 1981–December 1, 1981; Assistant Secretary of State for Democracy, Human Rights, and Labor, November 23, 1981–July 17, 1985; Assistant Secretary of State for Western Hemisphere Affairs, July 12, 1985–January 20, 1989.</li>
        <li>
            <a href="http://history.state.gov/departmenthistory/people/adams-david-s">Adams, David S.</a>
            (Non-career appointee, b. 1961): Assistant Secretary of State for Legislative Affairs, August 4, 2011–.</li>
        <li>
            <a href="http://history.state.gov/departmenthistory/people/adelman-kenneth-lee">Adelman, Kenneth Lee</a>
            (Non-career appointee, b. 1946): Director of the U.S. Arms Control and Disarmament Agency, April 14, 1983–December 12, 1987.</li>
        <!-- remaining results -->
    </ol>
</div>
xquery version "3.0";

(: Display a list of Principal Officers who are still alive who began serving on/after, or were serving as of, January 20, 1977. :)

let $all-people := collection('/db/cms/apps/principals-chiefs/data/')/person
let $principals := $all-people[.//role/@class='principal']
let $cutoff-date := '1977-01-20'
let $since-cutoff := $principals//role[@class='principal'][event[@type=('appointed', 'appointterminated')]/@when ge $cutoff-date]/ancestor::person
let $still-living := $since-cutoff[death/@type = 'unknown' or death = '' or empty(death/node())]
return 
    <div>
        <h1>Principal Officers since the Carter Adminstration</h1>
        <h2>{format-date(current-date(), '[MNn] [D], [Y]')}</h2>
        <p>Principal Officers who were serving on, or began service after, {format-date($cutoff-date, '[MNn] [D], [Y]')}, and who are still alive. There are {count($still-living)} entries. Note: Only terms of service as Principal Officer are shown; terms of service as Chief of Mission are not shown. Also, we do our best to monitor obituaries, but some people listed below may in fact have passed away. Please let us know if you discover any information that is out of date.</p>
        <ol>{
            for $principal in $still-living
            let $id := $principal/@id
            let $name := string-join(($principal/persName/surname, $principal/persName/forename, $principal/persName/genName[. ne '']), ', ')
            let $birth := if ($principal/birth ne '') then $principal/birth/string() else '?'
            let $principal-roles :=
                string-join(
                    for $role in $principal/role[@class='principal'][event]
                    let $role-label := collection('/db/cms/apps/principals-chiefs/code-tables/roles/data/')/role[id = $role/@type]/names/singular
                    let $start := $role/event[@type = 'appointed']/@when
                    let $end := $role/event[@type = 'appointmentterminated']/@when
                    order by $start
                    return
                        concat($role-label, ', ', format-date($start, '[MNn] [D], [Y]'), '–', if ($end ne '') then format-date($end, '[MNn] [D], [Y]') else '')
                    , 
                    '; ')
            let $career-type := $principal/career/string()
            order by $id
            return
                <li><a href="http://history.state.gov/departmenthistory/people/{$id}">{$name}</a> ({$career-type}, b. {$birth}): {$principal-roles}.</li>
        }</ol>
    </div>