Created
December 22, 2013 19:57
-
-
Save CliffordAnderson/8087645 to your computer and use it in GitHub Desktop.
Query for long and short phrases in Shakespeare's plays
This file contains hidden or 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.0"; | |
declare namespace tei="http://www.tei-c.org/ns/1.0"; | |
for $result in fn:collection("/db/shakespeare")//tei:ab | |
let $length := | |
if (fn:string-length($result) gt 20) then "long-phrase" | |
else "short-phrase" | |
group by $length | |
return element { $length } { count($result) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An example of using the "group by" keyword in XQuery 3.0 adapted from the corresponding BaseX documentation example to sort by distinct values.