xquery version "3.1"; declare namespace tei="http://www.tei-c.org/ns/1.0"; declare default element namespace "http://www.w3.org/1999/xhtml"; declare variable $Chas as document-node() := doc('http://exist.newtfire.org/exist/rest/db/mitford/literary/Charles1.xml'); declare variable $si as document-node() := doc('http://exist.newtfire.org/exist/rest/db/mitford/si.xml'); (: The global variables above are pointing into my eXist-dB from outside the system, so you can execute this XQuery in oXygen! :) My page of French Places in Charles I

Table of French Places in MRM's Charles I

{ let $places := $si//tei:place let $Chasplaces := $Chas//tei:placeName/@ref ! string() let $distChPRs := $Chasplaces => distinct-values() => sort() let $sequence := for $dist in $distChPRs let $siMatch := $places[@xml:id = substring-after($dist, '#')] (: We called this $siCPRs in the syllabus. :) (: :order by $siMatch/@xml:id :) where $siMatch[contains(., 'France')] return $siMatch for $s at $pos in $sequence return }
Position Number Id Full Name Note
{$pos} {$s/@xml:id ! string()} {$s/tei:placeName[1] ! string()} {$s/tei:note ! string()}