]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql_interpreter_galax/func.ml
No more useful
[helm.git] / helm / ocaml / mathql_interpreter_galax / func.ml
1 (* Copyright (C) 2000, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 (*
27  *
28  *)
29
30 open MathQL;;
31
32 (*
33  * implementazione della funzione NAME
34  *
35  * esempio:
36  * name "cic:/Algebra/CC_Props/CC_CauchySeq.ind#xpointer(1/1/1)" = CC_CauchySeq
37  *)
38 let func_name value =
39  try (
40   let i = Str.search_forward (Str.regexp "[^/]*\.") value 0 in
41    let s = Str.matched_string value in 
42     let retVal = Str.string_before s ((String.length s) - 1) in
43      retVal
44  ) with
45   Not_found -> ""
46 ;;
47
48 (*
49  *
50  *)
51 let func_theory value =
52  ""
53 ;;
54
55 (*
56  * implementazione delle funzioni dublin core
57  *)
58 let func_dc (value, name) =
59         let pathv = ("\"" ^ "/home/lorenzo/helm/metadata/dc" ^ value ^ "\"") in
60           let xq ="namespace rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
61                    namespace rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"
62                    namespace dc=\"http://purl.org/metadata/dublin_core#\"
63                    namespace dcq=\"http://purl.org/metadata/dublin_core_qualifiers#\"
64                    namespace h=\"http:/www.cs.unibo.it/helm/schemas/schema-h.rdf#\"
65                    namespace hth=\"http://www.cs.unibo.it/helm/schemas/schema-hth.rdf#\"
66                    
67                    for $i in document(" ^ pathv ^ ")//rdf:RDF//h:DirectoryOfObjects
68                     return $i//dc:" ^ name
69           in
70             let uril = Toputils.eval_query_string xq in (* e' una lista di liste di stringhe*)
71             let   hd_uril = List.hd uril in  (*prendo l'elemento in testa che e' quello che contiene la lista 
72                                              di uri, IN REALTA' ORA CONTIENE ALTERNATIVAMENTE UN URI E LA SUA                                              POSIZIONE!!  *)
73                 List.hd hd_uril
74
75
76
77 (*print_string (( List.hd hd_uril) ^ "NEW!");
78                 print_endline " [FINE]";*)
79
80
81
82                                                                                                                                                                                                                                                                                                                    (*List.iter (List.iter print_string) uril;*)
83
84                                                                                                                                                                                                                                                                                                                    ;;
85
86 (*
87  *
88  *)
89 let apply_func f value =
90  match f with
91     MQName         -> func_name value
92  |  MQTheory       -> func_theory value
93  |  MQTitle        -> func_dc (value, "title")
94  |  MQContributor  -> func_dc (value, "contributor")
95  |  MQCreator      -> func_dc (value, "creator")
96  |  MQPublisher    -> func_dc (value, "publisher")
97  |  MQSubject      -> func_dc (value, "subject")
98  |  MQDescription  -> func_dc (value, "description")
99  |  MQDate         -> func_dc (value, "date")
100  |  MQType         -> func_dc (value, "type")
101  |  MQFormat       -> func_dc (value, "format")
102  |  MQIdentifier   -> func_dc (value, "identifier")
103  |  MQLanguage     -> func_dc (value, "language")
104  |  MQRelation     -> func_dc (value, "relation")
105  |  MQSource       -> func_dc (value, "source")
106  |  MQCoverage     -> func_dc (value, "coverage")
107  |  MQRights       -> func_dc (value, "rights")
108  |  MQInstitution  -> func_dc (value, "institution")
109  |  MQContact      -> func_dc (value, "contact")
110  |  MQFirstVersion -> func_dc (value, "firstversion")
111  |  MQModified     -> func_dc (value, "modified")
112 ;;
113