Skip to content

Instantly share code, notes, and snippets.

@duncdrum
Created October 25, 2015 18:50
Show Gist options
  • Save duncdrum/3d2d97fc4989d87e33e5 to your computer and use it in GitHub Desktop.
Save duncdrum/3d2d97fc4989d87e33e5 to your computer and use it in GitHub Desktop.
New Territories WSC Query
xquery version "3.0";
declare namespace mods="http://www.loc.gov/mods/v3";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xlink="http://www.w3.org/1999/xlink";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
import module namespace functx="http://www.functx.com";
(:declare default element namespace "http://www.tei-c.org/ns/1.0";:)
declare variable $termdb := collection('/db/resources/commons/WSC/termdb/')//tei:body;
let $results :=
<entries>
<ziran>
{
for $nature in $termdb//tei:orth[. = '自然']
return
functx:distinct-deep($nature/ancestor::tei:entry)
}
</ziran>
<nature>{$termdb//*[contains(., 'nature')]/parent::tei:entry}</nature>
<huanjing>
{
for $env in $termdb//tei:orth[. = '環境']
return
functx:distinct-deep($env/ancestor::tei:entry)
}
</huanjing>
<environment>{$termdb//*[contains(., 'environment')]/parent::tei:entry}</environment>
</entries>
for $n in $results
return
<stats>
<nat-num>{count($results//nature/tei:entry)}</nat-num>
<env-num>{count($results//environment/tei:entry)}</env-num>
</stats>
(: <stats>
<nat-num>189</nat-num>
<env-num>6</env-num>
</stats> :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment