// cut and paste these queries into your own test file. // finds act, scene and speaker of famous // line "Et tu, Brute! Then fall, Caesar." // should return // // // CAESAR // ACT III // SCENE I. Rome. Before the Capitol; the Senate sitting above. // // // // // { for $a in document("j_caesar.xml")//ACT, $sc in $a//SCENE, $sp in $sc/SPEECH where $sp/LINE/text() = "Et tu, Brute! Then fall, Caesar." return {$sp/SPEAKER/text()}, {{$a/title/text()}, {$sc/title/text()}} } // group all acts by speaker, that is, return a list of elements // of type // element speaks { element who {String}, (element when {String})+ } // // where the String contents of the element is a speaker name, // and the contents of the elements are act names. for $s in document("j_caesar.xml")//SPEAKER return {{$s/text()}, for $a in document("j_caesar.xml")//ACT where some $s1 in $a//SPEAKER satisfies $s1 eq $s return {$a/title/text()}}