q4.cd 450 Bytes
Newer Older
1
include "tests/cql/TREE/type-TREE.cd";;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(* include "tests/cql/TREE/q4.cd";; *)

(* How many top-level sections are in Book1? *)

let fun count(x : [Any*]) : Int =
  let tr_count((Int,[Any*]) -> Int)
        |  (n,[]) -> n
        |  (n,[_;t]) -> tr_count(n+1,t)
   in tr_count(0,x);;
   
   
<top_section_count>(count([book]/Section));;



(* IN XQUERY 


<top_section_count>
 { 
   count(doc("book.xml")/book/section) 
 }
</top_section_count>



*)