q2.cd 620 Bytes
Newer Older
1
2
3
4
5
(*
Create a flat list of all the title-author pairs, 
with each pair enclosed in a "result" element.
*)

6
include "doc.cd";;
7

8
9
let q2x =
<results>
10
11
select <result>[!([b]/<title>_) a] 
from b in [doc]/<book>_,
12
13
14
15
16
17
18
19
     a in [b]/<author>_ ;; 
     
let q2p=
<results>
 select <result>[t a] 
 from <bib>[b::Book+] in [doc], 
      <book>[t&Title la::Author+ ;_] in b,
      a in la ;;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


(* in xquery 

<results>
  {
    for $b in doc("http://www.bn.com/bib.xml")/bib/book,
        $t in $b/title,
        $a in $b/author
    return
        <result>
            { $t }    
            { $a }
        </result>
  }
</results>



*)