]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql_interpreter_galax/2use.ml
9a69db2f9c2c6b5e6ed4bc97610f73fe5d70966e
[helm.git] / helm / ocaml / mathql_interpreter_galax / 2use.ml
1 open Mathql_semantics;;
2
3
4 (* prende una lista di uri (contenente alternativamente uri e pos) e costruisce una lista di attributed_uri *)
5 let rec attl uril svar = 
6
7             match uril with
8               | head::tail ->
9                 let suri = List.hd uril in
10         
11                  let uril_tl = List.tl uril in
12
13
14               {uri = suri; attributes = [(svar, (List.hd
15               uril_tl))]; extra = ""} :: attl (List.tl uril_tl) svar (*
16                                                 NON SONO SICURO DI AVER COSTRUITO BENE LA STRUTTURA DATI!!!!*)
17               | [] -> [] 
18
19
20
21
22
23 (* prende un attributed_uri e una svar e  restituisce la lista degli
24 attributed_uri (backward o forward in base al parametro "d") associando
25 la posizione alla var passata *)
26
27 let muse svar d path = 
28         let dir =
29           match d with
30               "F" -> "/home/projects/helm/metadata/create4/forward"
31             | _ -> "/home/projects/helm/metadata/create4/backward"
32         in 
33           let dtag =
34             match d with
35               "F" -> "refObj"
36             | _ -> "backPointer" in
37
38           let xq ="namespace h=\"http://www.cs.unibo.it/helm/schemas/mattone.rdf#\"
39                    namespace rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
40                 for $i in document(" ^ "\"" ^ dir ^ path.uri ^ "\"" ^
41                 ")//rdf:RDF//h:Object//h:" ^ dtag ^ "//h:Occurrence
42                 return ($i//h:occurrence, $i//h:position)"
43         
44           in 
45           print_endline xq;
46             let uril = Toputils.eval_query_string xq in (* e' una lista di liste di stringhe*)
47              let  hd_uril = List.hd uril in(*prendo l'elemento in testa che e' quello
48                                       che contiene la lista di uri*)
49         
50         attl hd_uril svar (* adesso dalla lista di uri(hd_uril) costruisco una lista di attributed_uri*)
51
52             
53
54
55 (* prende una lista di uri (Mathql_semantics.result), una variabile (a cui
56 associare la posizione), e la direzione (forward o backward) e per ogni uri chiama la muse *)
57 let use_ex ulist svar d = 
58       List.concat (List.map (muse svar d) ulist) 
59 ;;
60
61
62