declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare variable $si as document-node() := doc("https://digitalmitford.org/si.xml"); declare variable $Chas as document-node() := doc("https://raw.githubusercontent.com/ebeshero/UpTransformation/master/data/Charles1.xml"); declare variable $places as element(tei:place)* := $si/descendant::tei:place; declare variable $Chasplaces as element(tei:placeName)* := $Chas/descendant::tei:placeName; declare variable $Chas_placerefs as attribute(ref)* := $Chasplaces//@ref; declare variable $distinct-Chas_placerefs := distinct-values($Chas_placerefs); Places in Mary Mitford’s play “Charles I” { for $i at $pos in $distinct-Chas_placerefs let $si_match := $si//tei:place[@xml:id eq substring-after($i, '#')] where contains($si_match, "France") order by $pos descending count $counter return }
ID Name Note Original position Output position
{$si_match/@xml:id/string()} {$si_match/tei:placeName[1]/string()} {$si_match/tei:note[1]/string()} {$pos} {$counter}