Forked from CliffordAnderson/01-access-collection.xqy
Created
March 24, 2017 20:19
-
-
Save suellenstringer-hye/07909b04e3a95dc50c1be749bf9bb963 to your computer and use it in GitHub Desktop.
XQuery Samples for Blue Mountain Project
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"; | |
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
fn:collection("bluemountain-transcriptions")/tei:TEI |
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"; | |
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
fn:collection("bluemountain-transcriptions")/tei:TEI => fn:count() |
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"; | |
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) |
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
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 | |
} |
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"; | |
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)} |
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"; | |
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 |
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"; | |
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
fn:count(fn:collection("bluemountain-transcriptions")//tei:textLang/@mainLang) |
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"; | |
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 |
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"; | |
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()} |
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"; | |
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} |
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"; | |
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) |
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"; | |
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