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