]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql_interpreter/func.ml
let in implemented
[helm.git] / helm / ocaml / mathql_interpreter / 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 Dbconn;;
31 open Utility;;
32 open MathQL;;
33
34 (*
35  * implementazione della funzione NAME
36  *
37  * esempio:
38  * name "cic:/Algebra/CC_Props/CC_CauchySeq.ind#xpointer(1/1/1)" = CC_CauchySeq
39  *)
40 let func_name value =
41  try (
42   let i = Str.search_forward (Str.regexp "[^/]*\.") value 0 in
43    let s = Str.matched_string value in 
44     let retVal = Str.string_before s ((String.length s) - 1) in
45      retVal
46  ) with
47   Not_found -> ""
48 ;;
49
50 (*
51  *
52  *)
53 let func_theory value =
54  ""
55 ;;
56
57 (*
58  * implementazione delle funzioni dublin core
59  *)
60 let func_dc (value, name) =
61  let c = pgc ()
62  and p = helm_property_id name in
63   pgresult_to_string (c#exec ("select t" ^ p ^ ".att1 from t" ^ p ^ " where " ^ "t" ^ p ^ ".att0 = '" ^ value ^ "'"))
64 ;;
65
66 (*
67  *
68  *)
69 let apply_func f value =
70  match f with
71     MQName         -> func_name value
72  |  MQTheory       -> func_theory value
73  |  MQTitle        -> func_dc (value, "title")
74  |  MQContributor  -> func_dc (value, "contributor")
75  |  MQCreator      -> func_dc (value, "creator")
76  |  MQPublisher    -> func_dc (value, "publisher")
77  |  MQSubject      -> func_dc (value, "subject")
78  |  MQDescription  -> func_dc (value, "description")
79  |  MQDate         -> func_dc (value, "date")
80  |  MQType         -> func_dc (value, "type")
81  |  MQFormat       -> func_dc (value, "format")
82  |  MQIdentifier   -> func_dc (value, "identifier")
83  |  MQLanguage     -> func_dc (value, "language")
84  |  MQRelation     -> func_dc (value, "relation")
85  |  MQSource       -> func_dc (value, "source")
86  |  MQCoverage     -> func_dc (value, "coverage")
87  |  MQRights       -> func_dc (value, "rights")
88  |  MQInstitution  -> func_dc (value, "institution")
89  |  MQContact      -> func_dc (value, "contact")
90  |  MQFirstVersion -> func_dc (value, "firstversion")
91  |  MQModified     -> func_dc (value, "modified")
92 ;;
93