declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare default collation "http://www.w3.org/2013/collation/UCA?lang=cs-CZ"; let $sps := //tei:sp let $whos := distinct-values($sps/@who) let $persons := for $who in $whos order by $who let $speakers := $sps[@who = $who]/tei:speaker return (: returns 'GA' and 'IO' with Saxon-HE XQuery 12.3, but 'GA' and 'IO' with Saxon-PE and Saxon-EE :) return List of characters {$persons}