Last active
August 29, 2015 14:02
-
-
Save fordmadox/f3639d28e54a4d21773f to your computer and use it in GitHub Desktop.
updated to output well-formed XML, rather than just an XML fragment; also, the return clause in the previous query output all of the stage elements, not the filtered list
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"; | |
(: | |
for each person, show stage directions involving that | |
person | |
:) | |
<people-plus-stage-directions> | |
{ | |
for $person in //tei:person | |
(: using a map isn't required here, I don't think :) | |
let $st := //tei:stage[@who/tokenize(., '#| #') = $person/@xml:id] | |
(: the next variable is used to isolate those stage direction that apply ONLY to the current person :) | |
let $st-lone := //tei:stage[@who eq $person/concat('#', @xml:id)] | |
order by count($st) descending, count($st-lone) descending | |
return | |
<person> | |
{ $person/@who, $person/@xml:id } | |
<name>{data($person/tei:persName/normalize-space(.))}</name> | |
<stage-directions total="{count($st)}" total-solo="{count($st-lone)}"> | |
{ | |
for $s in $st | |
return | |
<sd>{ $s/@who, $s/@xml:id } </sd> | |
} | |
</stage-directions> | |
</person> | |
} | |
</people-plus-stage-directions> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment