(:######################## START: FLWR ########################:)
(:Returns 39 nodes:)
{for $a in document("j_caesar.xml")//ACT, $s1 in $a//SPEAKER
where ($s1/text() eq "CAESAR")
return {{$s1/text()},
{$a/TITLE/text()}}}
;
(:######################## END: FLWR ########################:)
(:######################## START: cond_Some ########################:)
(:### Should return nothing since the text() compressor isn't provided in the condition:)
{for $a in document("j_caesar.xml")//ACT
where some $s1 in $a//SPEAKER satisfies $s1 eq "TREBONIUS"
return {$a/TITLE/text()}}
;
(:returns :)
(: :)
(: ACT II:)
(: ACT III:)
(: :)
{for $a in document("j_caesar.xml")//ACT
where some $s1 in $a//SPEAKER satisfies $s1/text() eq "TREBONIUS"
return {$a/TITLE/text()}}
;
(:######################## END: cond_Some ########################:)
(:######################## START: Nested ########################:)
{
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/text() eq $s
return {$a/TITLE/text()}}
};
(:######################## START: Nested ########################:)
for $character in document("j_caesar.xml")//SPEAKER
let $check := "CAESAR"
where ($character/text() eq $check)
return {{$character},
{$check}};
for $character in document("j_caesar.xml")//SPEAKER
let $a := $character/../../..//TITLE
where ($character/text() eq "CAESAR")
return {{$character},
{$a}};
for $character in distinct-values(//SPEAKER)
let $speeches := count(//SPEECH[SPEAKER = $character])
where $speeches > 100
return ;
for $line in //ACT[TITLE = "ACT III"]/SCENE[TITLE = "SCENE II"]/SPEECH[SPEAKER = "BRUTUS"]/LINE
return $line;
for $act in doc("j_caesar.xml")/PLAY/ACT,
$scene in $act/SCENE,
$speech in $scene/SPEECH[SPEAKER = 'BRUTUS']
return
{
{$speech/SPEAKER/text()},
{$speech}
};
(:The above query is equivalent to the next one. This returns 194 speech nodes:)
for $act in doc("j_caesar.xml")/PLAY/ACT,
$scene in $act/SCENE,
$speaker in $scene/SPEECH/SPEAKER
where $speaker = "BRUTUS"
return
{
{$speaker/text()},
{$speaker/../../TITLE/text()}
};
for $line in document("j_caesar.xml")//LINE
where $line/../SPEAKER = "BRUTUS"
return $line/text();
(:let $speakers := document("j_caesar.xml")//SPEAKER:)
(:let $lines := for $speaker in $speakers:)
(: return {$speaker/../LINE}:)
(:$speakers[$lines/text() = "Et tu, Brute! Then fall, Caesar."]/text();:)
(:let $speakers := document("j_caesar.xml")//SPEAKER,:)
(:$lines := for $speaker in $speakers:)
(: where $speaker/../LINE = "Et tu, Brute! Then fall, Caesar.":)
(: return {$speaker/../LINE}:)
(:{$speakers/text()};:)
for $speaker in document("j_caesar.xml")//SPEAKER,
$line in let $k := document("j_caesar.xml")//TITLE
for $node in $k
return
{$k}
where $line/text() eq "SCENE II. A public place." and $speaker/text() eq "Soothsayer"
return {$speaker/../LINE};
(:######################## START: MS2 ########################:)
{
for $a in (for $s in doc("j_caesar.xml")//ACT return $s),$sc in (for $t in $a/SCENE return $t), $sp in (for $d in $sc/SPEECH return $d)
where $sp/LINE/text() = "Et tu, Brute! Then fall, Caesar."
return
{$sp/SPEAKER/text()},{ {$a/TITLE/text()},
{$sc/TITLE/text()} } };
{
for $a in doc("j_caesar.xml")//PERSONAE, $b in $a/PERSONA where not (($b/text() = "JULIUS CAESAR") or ($b/text() = "Another Poet") )
return $b };
{
for $a in doc("j_caesar.xml")//ACT
where not empty (
for $sp in $a/SCENE/SPEECH
where ($sp/SPEAKER/text() = "FLAVIUS" and $sp/../TITLE/text()="SCENE I. Rome. A street.")
return { $sp/text() } )
return {$a/TITLE/text()} };
{
for $a in doc("j_caesar.xml")//ACT
where some $s1 in (for $x in $a//SCENE
where $x/TITLE/text()="SCENE II. A public place."
return $x)
satisfies $s1//SPEAKER eq "CAESAR" and $a/TITLE/text() = "ACT I"
return {$a/TITLE/text()}};
{for $s in doc("j_caesar.xml")//SCENE
where $s//SPEAKER/text()="CAESAR"
return { {$s/TITLE/text()} }
{
for $s in doc("j_caesar.xml")//SCENE
where $s//SPEAKER/text()="CAESAR"
return { {$s/TITLE/text()} , for $a in doc("j_caesar.xml")//ACT
where some $s1 in (for $x in $a//SCENE
where $x/TITLE/text()="SCENE II. A public place."
return $x)
satisfies $s1 eq $s and $a/TITLE/text() = "ACT I"
return {$a/TITLE/text()}}};
{
for $a in (for $s in doc("j_caesar.xml")//ACT where $s/TITLE/text()="ACT I" return $s), $sc in
(for $t in $a/SCENE where $t/TITLE/text()="SCENE I. Rome. A street." return $t), $sp in (for $d in
$sc/SPEECH where $d/LINE/text()="Upon a labouring day without the sign" return $d)
where $sp/SPEAKER/text() = "FLAVIUS"
return {$sp/SPEAKER/text()},{ {$a/TITLE/text()},
{$sc/TITLE/text()} } };
{
for $a in (for $s in doc("j_caesar.xml")//ACT return $s), $sc in (for $t in $a/SCENE return $t),
$sp in (for $d in $sc/SPEECH return $d) where $sp/LINE/text() = "Et tu, Brute! Then fall, Caesar."
return {$sp/SPEAKER/text()},
{ {$a/TITLE/text()}, {$sc/TITLE/text()} } };
{
for $a in doc("j_caesar.xml")//ACT
where empty ( for $sp in $a/SCENE/SPEECH/SPEAKER
where $sp/text() = "CASCA"
return {$sp/text()})
return {$a/TITLE/text()}} ;
{
for $a in doc("j_caesar.xml")//PERSONAE, $b in $a/PERSONA
where ($b/text() = "JULIUS CAESAR") or ($b/text()= "Another Poet")
return $b };
{
for $b in doc("j_caesar.xml")//ACT
let $a:= $b/SCENE
where $a/SPEECH/SPEAKER/text()="MARULLUS"
return {$a} };
{
let $a:= doc("j_caesar.xml")//ACT
for $b in $a/SCENE
where $b/SPEECH/SPEAKER/text()="MARULLUS"
return {$b} };
(:######################## START: Joins ########################:)
for $tuple in join (join (for $b2 in doc("j_caesar.xml")//SPEECH, $tb2 in $b2/SPEAKER
where $tb2 = "FLAVIUS"
return {$b2}, {$tb2},
for $b3 in doc("j_caesar.xml")//ACT, $tb3 in $b3//SPEAKER
where $b3/TITLE = "ACT I"
return {$b3}, {$tb3},
[tb2], [tb3]),
for $b1 in doc("j_caesar.xml")//PGROUP, $tb1 in $b1/PERSONA
return {$b1}, {$tb1},
[tb3], [tb1])
return
{$tuple/b1/*/PERSONA, $tuple/b2/*/SPEAKER, $tuple/b3/*/SCENE/TITLE};
for $tuple in join (join (for $b2 in doc("j_caesar.xml")//SPEECH, $tb2 in $b2/SPEAKER
where $tb2 = "PUBLIUS"
return {$b2}, {$tb2},
for $b3 in doc("j_caesar.xml")//ACT, $tb3 in $b3/..//SPEAKER
where $b3/TITLE = "ACT II"
return {$b3}, {$tb3},
[tb2], [tb3]),
for $b1 in doc("j_caesar.xml")//PGROUP, $tb1 in $b1/PERSONA
return {$b1}, {$tb1},
[tb3], [tb1])
return
{$tuple/b1/*, $tuple/b2/*, $tuple/b3/*};
for $tuple in join (join (join (for $b2 in doc("j_caesar.xml")//SPEECH, $tb2 in $b2/SPEAKER
where $tb2 = "PUBLIUS"
return {$b2}, {$tb2},
for $b3 in doc("j_caesar.xml")//ACT, $tb3 in $b3/..//SPEAKER
where $b3/TITLE = "ACT II"
return {$b3}, {$tb3},
[tb2], [tb3]),
for $b1 in doc("j_caesar.xml")//PGROUP, $tb1 in $b1/PERSONA
return {$b1}, {$tb1},
[tb3], [tb1]),
for $b4 in doc("j_caesar.xml")//ACT, $tb4 in $b4/SCENE/TITLE
where $tb4 = "SCENE II. CAESAR's house."
return {$b4}, {$tb4},
[b3], [b4])
return
{$tuple/b1/*, $tuple/b2/*, $tuple/tb3/*, $tuple/tb4/*};
for $tuple in join (join (for $b2 in doc("j_caesar_M3.xml")//SPEECH, $tb2 in $b2/SPEAKER
where $tb2 = "FLAVIUS"
return {$b2}, {$tb2},
for $b3 in doc("j_caesar_M3.xml")//ACT, $tb3 in $b3/..//SPEAKER
where $b3/TITLE = "ACT I"
return {$b3}, {$tb3},
[tb2], [tb3]),
for $b1 in doc("j_caesar_M3.xml")//PGROUP, $tb1 in $b1/PERSONA
return {$b1}, {$tb1},
[tb3], [tb1])
return
{$tuple/b1/*, $tuple/b2/*, $tuple/b3/*};