Skip to content

Instantly share code, notes, and snippets.

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 suellenstringer-hye/07909b04e3a95dc50c1be749bf9bb963 to your computer and use it in GitHub Desktop.
Save suellenstringer-hye/07909b04e3a95dc50c1be749bf9bb963 to your computer and use it in GitHub Desktop.
XQuery Samples for Blue Mountain Project
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
fn:collection("bluemountain-transcriptions")/tei:TEI
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
fn:collection("bluemountain-transcriptions")/tei:TEI => fn:count()
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $languages := fn:collection("bluemountain-transcriptions")//tei:langUsage/tei:language
return fn:distinct-values($languages)
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $languages := fn:collection("bluemountain-transcriptions")//tei:langUsage/tei:language
for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where fn:count($doc//tei:langUsage/tei:language) gt 1
return
element doc {attribute uri {fn:base-uri($doc)},
for $language in $doc//tei:langUsage/tei:language
return $language
}
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where fn:count($doc//tei:langUsage/tei:language) eq 1
group by $language := $doc//tei:langUsage/tei:language
order by fn:count($doc) descending
return element {$language} {fn:count($doc)}
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $language-indicator :=
(for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where ($doc//tei:langUsage)
return fn:base-uri($doc)) => fn:count()
let $no-language-indicator :=
(for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where fn:not($doc//tei:langUsage)
return fn:base-uri($doc)) => fn:count()
return fn:round(($language-indicator div $no-language-indicator) * 100) div 100
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
fn:count(fn:collection("bluemountain-transcriptions")//tei:textLang/@mainLang)
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $language-indicator :=
(for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where ($doc//tei:textLang/@mainLang)
return fn:base-uri($doc)) => fn:count()
let $no-language-indicator :=
(for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where fn:not($doc//tei:textLang/@mainLang)
return fn:base-uri($doc)) => fn:count()
return fn:round(($no-language-indicator div $language-indicator) * 100) div 100
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
where $doc//tei:textLang/@mainLang
return element languages {attribute uri {fn:base-uri($doc)}, $doc//tei:textLang/@mainLang/string()}
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
for $doc in fn:collection("bluemountain-transcriptions")//tei:TEI
let $languages := $doc//tei:textLang/@mainLang/string()
let $distinct-languages := fn:distinct-values($languages)
where fn:count($distinct-languages) gt 1
return element journal {attribute uri {fn:base-uri($doc)}, $distinct-languages}
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
(: Create new database for French documents :)
let $fre-docs := fn:collection("bluemountain-transcriptions")[//tei:language/text() = "French"]
let $uri-docs := for $doc in $fre-docs return fn:base-uri($doc)
return db:create("fre-bmp", $fre-docs, $uri-docs)
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
for $doc in fn:collection("fre-bmp")
return fn:base-uri($doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment