Last active
August 29, 2015 14:02
-
-
Save jonathanrobie/05a5f394a94d5f9d1cd3 to your computer and use it in GitHub Desktop.
Caesar's entrances and exits - using sliding windows
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 default element namespace "http://www.tei-c.org/ns/1.0"; | |
declare function local:is-person($s as element(stage), $who as xs:string) | |
as xs:boolean | |
{ | |
$s/@who ! tokenize(., "(#)|( #)") = $who | |
}; | |
declare function local:enter-and-exit($act as element(div1), $scene as element(div2), $who as xs:string) | |
{ | |
for sliding window $onstage in $scene//stage | |
start $entrance when local:is-person($entrance, $who) and $entrance/@type='entrance' | |
end $exit when local:is-person($exit, $who) and ($exit/@type = 'exit' or ($exit/@type = 'business' and $exit/w = 'dies')) | |
return | |
<window act="{$act/@n}" scene="{$scene/@n}"> | |
<enter>{ $entrance/@n, $entrance/@who, $entrance//(w | c | pc)/text() }</enter> | |
<exit>{ $exit/@n, $exit/@who, $exit//(w | c | pc)/text() }</exit> | |
</window> | |
}; | |
for $act in //div1[@type='act'] | |
for $scene in $act//div2[@type='scene'] | |
return local:enter-and-exit($act, $scene, 'Caesar_JC') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Query from http://xqueryinstitute.org/ workshop, June 2014. Input is Folger's edition of Julius Caesar.
This query has the same functionality as https://gist.github.com/jonathanrobie/760032f9c9a304be7045, but is made simpler and more optimizable by using sliding windows.
Obviously, you can get a synopsis of other characters by changing the 'Caesar_JC' to the name of another character, e.g. 'Brutus_JC'. Looking at the characters with the most lines, how does each character exit the last time?