eval.cmi: mathql.cmo
+func.cmi: mathql.cmo
+sortedby.cmi: mathql.cmo
select.cmi: mathql.cmo
pattern.cmi: mathql.cmo
mqint.cmi: mathql.cmo
dbconn.cmx: mathql.cmx dbconn.cmi
eval.cmo: mathql.cmo eval.cmi
eval.cmx: mathql.cmx eval.cmi
-utility.cmo: utility.cmi
-utility.cmx: utility.cmi
-func.cmo: func.cmi
-func.cmx: func.cmi
+utility.cmo: dbconn.cmi utility.cmi
+utility.cmx: dbconn.cmx utility.cmi
+func.cmo: dbconn.cmi mathql.cmo utility.cmi func.cmi
+func.cmx: dbconn.cmx mathql.cmx utility.cmx func.cmi
+diff.cmo: diff.cmi
+diff.cmx: diff.cmi
+sortedby.cmo: func.cmi mathql.cmo utility.cmi sortedby.cmi
+sortedby.cmx: func.cmx mathql.cmx utility.cmx sortedby.cmi
select.cmo: func.cmi mathql.cmo utility.cmi select.cmi
select.cmx: func.cmx mathql.cmx utility.cmx select.cmi
intersect.cmo: intersect.cmi
pattern.cmx: dbconn.cmx eval.cmx utility.cmx pattern.cmi
use.cmo: dbconn.cmi utility.cmi use.cmi
use.cmx: dbconn.cmx utility.cmx use.cmi
-mqint.cmo: dbconn.cmi eval.cmi intersect.cmi mathql.cmo pattern.cmi \
- select.cmi union.cmi use.cmi utility.cmi mqint.cmi
-mqint.cmx: dbconn.cmx eval.cmx intersect.cmx mathql.cmx pattern.cmx \
- select.cmx union.cmx use.cmx utility.cmx mqint.cmi
+mqint.cmo: dbconn.cmi diff.cmi eval.cmi intersect.cmi mathql.cmo pattern.cmi \
+ select.cmi sortedby.cmi union.cmi use.cmi utility.cmi mqint.cmi
+mqint.cmx: dbconn.cmx diff.cmx eval.cmx intersect.cmx mathql.cmx pattern.cmx \
+ select.cmx sortedby.cmx union.cmx use.cmx utility.cmx mqint.cmi
REQUIRES = helm-urimanager pgocaml
PREDICATES =
-INTERFACE_FILES = dbconn.mli eval.mli utility.mli func.mli \
- select.mli intersect.mli union.mli pattern.mli use.mli \
- mqint.mli
+INTERFACE_FILES = dbconn.mli eval.mli utility.mli func.mli diff.mli \
+ sortedby.mli select.mli intersect.mli union.mli \
+ pattern.mli use.mli mqint.mli
IMPLEMENTATION_FILES = mathql.ml $(INTERFACE_FILES:%.mli=%.ml)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* gestione della connessione al database
*)
(*
- * le eccezzioni lanciate dalle funzioni init e pgc sono
+ * le eccezioni lanciate dalle funzioni init e pgc sono
* definite nel modulo Mathql
*)
open Mathql;;
(*
* paramentri della connessione
+ *
+ * TODO: bisogna scegliere se questi parametri vengono
+ * passati come argomento
*)
-(*let connection_param = "host=127.0.0.1 dbname=helm";;*)
+(*let connection_param = "dbname=helm";;*)
let connection_param = "host=dotto.cs.unibo.it dbname=helm user=helm";;
(*
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val pgc : unit -> Postgres.connection
val init : unit -> unit
val close : unit -> unit
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(*
+ * implementazione del comando DIFF
+ *)
+
+(*
+ *
+ *)
+let xres_fill_context hr h1 l1 =
+ match l1 with
+ [] -> []
+ | _ ->
+ let hh = List.combine h1 l1
+ in
+ List.map
+ (fun x ->
+ if (List.mem_assoc x hh) then
+ List.assoc x hh
+ else
+ ""
+ )
+ hr
+;;
+
+(*
+ * implementazione del comando DIFF
+ *)
+let diff_ex alist1 alist2 =
+ let head1 = List.hd alist1
+ and tail1 = List.tl alist1
+ and head2 = List.hd alist2
+ and tail2 = List.tl alist2 (* e fin qui ... *)
+ in
+ match (head1, head2) with
+ ([], _) -> assert false (* gli header non devono mai essere vuoti *)
+ | (_, []) -> assert false (* devono contenere almeno [retVal] *)
+ | (_, _) -> let headr = (head2 @
+ (List.find_all
+ (function t -> not (List.mem t head2))
+ head1)
+ ) in (* header del risultato finale *)
+ List.append (* il risultato finale e' la concatenazione ...*)
+ [headr] (* ... dell'header costruito prima ...*)
+ (match (tail1, tail2) with (* e di una coda "unione" *)
+ ([], _) -> tail2 (* va bene perche' l'altra lista e' vuota *)
+ | (_, []) -> tail1 (* va bene perche' l'altra lista e' vuota *)
+ | (_, _) ->
+ let first = (* parte dell'unione che riguarda solo il primo set *)
+ List.map (fun l -> [List.hd l] @
+ xres_fill_context
+ (List.tl headr) (List.tl head1) (List.tl l)
+ ) tail1
+ in
+ List.fold_left
+ (fun par x ->
+ let y = (* elemento candidato ad entrare *)
+ [List.hd x]
+ @
+ xres_fill_context
+ (List.tl headr) (List.tl head2) (List.tl x)
+ in
+ par @ if (List.find_all (fun t -> t = y) par) = [] then
+ [y]
+ else
+ []
+ )
+ first
+ tail2
+(* first @
+ List.map (fun l -> [List.hd l] @
+ xres_fill_context
+ (List.tl headr) (List.tl head2) (List.tl l)
+ ) tail2
+*)
+ ) (* match *)
+;;
+
+(** TEST **)
+
+(*
+let h1 = ["retVal"; "a"; "b"];;
+let l1 = ["pippo"; "3"; "3"];;
+let l3 = ["pluto"; "7"; "8"]
+let r1 = [h1; l1; l3];;
+
+(*let h2 = ["retVal"; "b"; "c"];;
+let l2 = ["pippo"; "3"; "1"];;*)
+let h2 = ["retVal"; "a"; "b"];;
+let l2 = ["pippo"; "3"; "3"];;
+let r2 = [h2; l2];;
+
+List.map (fun l -> List.iter print_endline l) (xres_union (r1, r2));;
+*)
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+val diff_ex : string list list -> string list list -> string list list
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
*
[] -> ""
| head::tail ->
let h = match head with
- MQString (s) -> s
+ MQString (s) -> Str.global_replace (Str.regexp "\.") "\\\\\." s
| MQSlash -> "/"
| MQAnyChr -> "[^/]?"
| MQAst -> "[^/]*"
match fst fi with
None -> ""
| Some i ->
- let s = "#xpointer\(1/" ^ string_of_int (i) in
+ let s = "#xpointer\\\\(1/" ^ string_of_int (i) in
match snd fi with
None ->
- s ^ "\)"
+ s ^ "\\\\)"
| Some j ->
- s ^ "/" ^ string_of_int j ^ "\)"
+ s ^ "/" ^ string_of_int j ^ "\\\\)"
+;;
+
+(*
+ * valuta l'estensione
+ *
+ * 20/05/2002: non piu' necessario: l'estensione fa eventualmente
+ * parte del pattern precedente
+ *)
+let exteval ext =
+ match ext with
+ "" -> ""
+ | _ -> ("\." ^ ext)
+;;
+
+(*
+ * valuta il preambolo
+ *)
+let preeval p =
+ p
;;
(*
* SQL standard LIKE perche' MathQL prevede esperssioni con "*"
* e con "**".
*)
-let pattern_match preamble pattern ext fragid =
- " ~ '" ^ preamble ^ ":/" ^ (patterneval pattern) ^ "." ^ ext ^ (fieval fragid) ^ "'"
+let pattern_match preamble pattern fragid =
+ " ~ '" ^ (preeval preamble) ^ ":/" ^ (patterneval pattern) ^ (fieval fragid) ^ "'"
;;
+
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val pattern_match :
string ->
- Mathql.mquptoken list -> string -> int option * int option -> string
+ Mathql.mquptoken list -> int option * int option -> string
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
*
*)
+open Dbconn;;
+open Utility;;
+open Mathql;;
+
(*
* implementazione della funzione NAME
*)
Not_found -> ""
;;
-(** TEST **)
+(*
+ *
+ *)
+let func_theory value =
+ ""
+;;
(*
-print_endline (func_name Sys.argv.(1));;
-*)
+ * implementazione delle funzioni dublin core
+ *)
+let func_dc (value, name) =
+ let c = pgc ()
+ and p = helm_property_id name in
+ pgresult_to_string (c#exec ("select t" ^ p ^ ".att1 from t" ^ p ^ " where " ^ "t" ^ p ^ ".att0 = '" ^ value ^ "'"))
+;;
+
+(*
+ *
+ *)
+let apply_func f value =
+ match f with
+ MQName -> func_name value
+ | MQTheory -> func_theory value
+ | MQTitle -> func_dc (value, "title")
+ | MQContributor -> func_dc (value, "contributor")
+ | MQCreator -> func_dc (value, "creator")
+ | MQPublisher -> func_dc (value, "publisher")
+ | MQSubject -> func_dc (value, "subject")
+ | MQDescription -> func_dc (value, "description")
+ | MQDate -> func_dc (value, "date")
+ | MQType -> func_dc (value, "type")
+ | MQFormat -> func_dc (value, "format")
+ | MQIdentifier -> func_dc (value, "identifier")
+ | MQLanguage -> func_dc (value, "language")
+ | MQRelation -> func_dc (value, "relation")
+ | MQSource -> func_dc (value, "source")
+ | MQCoverage -> func_dc (value, "coverage")
+ | MQRights -> func_dc (value, "rights")
+ | MQInstitution -> func_dc (value, "institution")
+ | MQContact -> func_dc (value, "contact")
+ | MQFirstVersion -> func_dc (value, "firstversion")
+ | MQModified -> func_dc (value, "modified")
+;;
+
-val func_name : string -> string
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+val apply_func: Mathql.mqfunc -> string -> string
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* implementazione del comando INTERSECT
) (* match *)
;;
-(*
-let h1 = ["retVal"; "a"; "b"];;
-let l1 = ["pippo"; "3"; "3"];;
-let l3 = ["pluto"; "7";"8"]
-let r1 = [h1; l1; l3];;
-
-let h2 = ["retVal"; "b"; "c"];;
-let l2 = ["pippo"; "3"; "1"];;
-let r2 = [h2; l2];;
-
-List.map (fun l -> List.iter print_endline l) (xres_intersect (r1, r2));;
-*)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val intersect_ex : string list list -> string list list -> string list list
(* Input types **************************************************************)
(* main type is mquery *)
-type mqrvar = string (* name *)
+type mqrvar = string (* name *)
-type mqsvar = string (* name *)
+type mqsvar = string (* name *)
type mquptoken =
- | MQString of string (* a constant string *)
- | MQSlash (* a slash: '/' *)
- | MQAnyChr (* Any single character: '?' *)
- | MQAst (* single asterisk: '*' *)
- | MQAstAst (* double asterisk: '**' *)
+ | MQString of string (* a constant string *)
+ | MQSlash (* a slash: '/' *)
+ | MQAnyChr (* Any single character: '?' *)
+ | MQAst (* single asterisk: '*' *)
+ | MQAstAst (* double asterisk: '**' *)
-type mqup = mquptoken list (* uri pattern (helper) *)
+type mqup = mquptoken list (* uri pattern (helper) *)
type mqfi = int option * int option
-type mqtref = string * mqup * string * mqfi (* HELM preamble,
- uri pattern,
- extension,
- fragment identifier *)
+type mqtref = string * mqup * mqfi (* HELM preamble,
+ uri pattern,
+ fragment identifier *)
-type mqpattern = mqtref (* constant pattern *)
+type mqpattern = mqtref (* constant pattern *)
type mqfunc =
- | MQName (* NAME *)
+ | MQName (* NAME *)
+ | MQTheory
+ | MQTitle
+ | MQContributor
+ | MQCreator
+ | MQPublisher
+ | MQSubject
+ | MQDescription
+ | MQDate
+ | MQType
+ | MQFormat
+ | MQIdentifier
+ | MQLanguage
+ | MQRelation
+ | MQSource
+ | MQCoverage
+ | MQRights
+ | MQInstitution
+ | MQContact
+ | MQFirstVersion
+ | MQModified
type mqstring =
- | MQCons of string (* constant *)
- | MQFunc of mqfunc * mqrvar (* function, rvar *)
- | MQRVar of mqrvar (* rvar *)
- | MQSVar of mqsvar (* svar *)
- | MQMConclusion (* main conclusion *)
- | MQConclusion (* inner conclusion *)
+ | MQCons of string (* constant *)
+ | MQFunc of mqfunc * mqrvar (* function, rvar *)
+ | MQRVar of mqrvar (* rvar *)
+ | MQSVar of mqsvar (* svar *)
+ | MQMConclusion (* main conclusion *)
+ | MQConclusion (* inner conclusion *)
type mqbool =
| MQTrue
| MQAnd of mqbool * mqbool
| MQOr of mqbool * mqbool
| MQNot of mqbool
- | MQIs of mqstring * mqstring (* operands *)
+ | MQIs of mqstring * mqstring (* operands *)
+
+type mqorder =
+ | MQAsc
+ | MQDesc
type mqlist =
- | MQSelect of mqrvar * mqlist * mqbool (* rvar, list, boolean *)
- | MQUse of mqlist * mqsvar (* list, Position attribute *)
- | MQUsedBy of mqlist * mqsvar (* list, Position attribute *)
- | MQPattern of mqpattern (* pattern *)
- | MQUnion of mqlist * mqlist (* *)
- | MQIntersect of mqlist * mqlist (* *)
+ | MQSelect of mqrvar * mqlist * mqbool (* rvar, list, boolean *)
+ | MQUse of mqlist * mqsvar (* list, Position attribute *)
+ | MQUsedBy of mqlist * mqsvar (* list, Position attribute *)
+ | MQPattern of mqpattern (* pattern *)
+ | MQUnion of mqlist * mqlist (* *)
+ | MQDiff of mqlist * mqlist (* *)
+ | MQIntersect of mqlist * mqlist (* *)
+ | MQSortedBy of mqlist * mqorder * mqfunc (* *)
type mquery =
| MQList of mqlist
(* Output types *************************************************************)
(* main type is mqresult *)
-(* TODO: usare le uri in questo formato *)
-type mquref = UriManager.uri * mqfi (* uri, fragment identifier *)
+type mquref = UriManager.uri * mqfi (* uri, fragment identifier *)
-type mqrefs = string list (* list of references (helper) *)
+type mqrefs = mqtref list (* list of references (helper) *)
type mqresult =
| MQRefs of mqrefs
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* implementazione del'interprete MathQL
open Pattern;;
open Union;;
open Intersect;;
+open Diff;;
+open Sortedby;;
open Use;;
open Select;;
+let fi_to_string fi =
+ match fi with
+ (None, _) ->
+ ""
+ | (Some i, y) ->
+ "#xpointer(1/" ^
+ string_of_int i ^
+ (
+ match y with
+ None ->
+ ""
+ | Some j ->
+ "/" ^ (string_of_int j)
+ ) ^
+ ")"
+;;
+
(*
* inizializzazione della connessione al database
*)
use_ex (execute_ex alist) asvar "refObj"
| MQUse (alist, asvar) ->
use_ex (execute_ex alist) asvar "backPointer"
- | MQPattern (apreamble, apattern, ext, afragid) ->
- pattern_ex apreamble apattern ext afragid
+ | MQPattern (apreamble, apattern, afragid) ->
+ let _ = print_endline ("*********" ^ (fi_to_string afragid)); flush stdout in
+ pattern_ex apreamble apattern afragid
| MQUnion (l1, l2) ->
union_ex (execute_ex l1) (execute_ex l2)
+ | MQDiff (l1, l2) ->
+ diff_ex (execute_ex l1) (execute_ex l2)
+ | MQSortedBy (l, o, f) ->
+ sortedby_ex (execute_ex l) o f
| MQIntersect (l1, l2) ->
intersect_ex (execute_ex l1) (execute_ex l2)
;;
* la uri puo' far parte del risultato.
*)
let xres_to_res l =
- MQRefs
- (
- List.map
- List.hd
- (List.tl l)
- )
+ let tmp = List.map List.hd (List.tl l) in
+ MQRefs
+ (List.map
+ (function l ->
+ match Str.split (Str.regexp ":\|#\|/") l with
+ hd::tl -> (
+ match List.rev tl with
+ ")"::n::"xpointer(1"::tail ->
+ (
+ hd,
+ List.fold_left
+ (fun par t ->
+ match par with
+ [] -> [MQString t]
+ | _ -> (MQString t) :: MQSlash :: par
+ )
+ []
+ tail,
+ (Some (int_of_string n), None)
+ )
+ | ")"::n::m::"xpointer(1"::tail ->
+ (
+ hd,
+ List.fold_left
+ (fun par t ->
+ match par with
+ [] -> [MQString t]
+ | _ -> (MQString t) :: MQSlash :: par
+ )
+ []
+ tail,
+ (Some (int_of_string m), Some (int_of_string n))
+ )
+ | tail ->
+ (
+ hd,
+ List.fold_left
+ (fun par t ->
+ match par with
+ [] -> [MQString t]
+ | _ -> (MQString t) :: MQSlash :: par
+ )
+ []
+ tail,
+ (None, None)
+ )
+ )
+ | [] -> assert false
+ )
+ tmp
+ )
;;
+
(*
*
*)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* interfaccia dell'interprete MathQL
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(*
+ * implementazione del comando PATTERN
+ *)
open Dbconn;;
open Utility;;
open Eval;;
-let pattern_ex apreamble apattern ext afragid =
+let pattern_ex apreamble apattern afragid =
let c = pgc () in
- let r1 = c#exec "select att0 from class where att2='Object'" in
- let res =
- c#exec ("select att0 from t" ^ (pgresult_to_string r1) ^
- " where att0 " ^ (pattern_match apreamble apattern ext afragid))
- in
- [["retVal"]] @ List.map (fun l -> [l]) (pgresult_to_string_list res)
+ let r1 = helm_class_id "MathResource" in
+ let qq = "select att0 from t" ^ r1 ^ " where att0 " ^ (pattern_match apreamble apattern afragid) in
+ (*let _ = print_endline qq in*)
+ let res =
+ c#exec (qq)
+ in
+ [["retVal"]] @ List.map (fun l -> [l]) (pgresult_to_string_list res)
;;
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val pattern_ex :
string ->
Mathql.mquptoken list ->
- string -> int option * int option -> string list list
+ int option * int option -> string list list
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* implementazione del comando SELECT
MQCons s ->
s
| MQFunc (f, rvar) ->
- (
- match f with
- MQName -> func_name (List.assoc rvar l)
- )
+ apply_func f (List.assoc rvar l)
| MQRVar rvar ->
List.assoc rvar l
| MQSVar svar ->
| _ -> l (* i casi non compresi sono MQTrue e MQFalse *)
;;
-let rec print_booltree b =
+(*let rec print_booltree b =
match b with
MQAnd (b1, b2) ->
let i = print_booltree b1 in
| MQFunc (f, rvar) ->
(
match f with
- MQName -> "NAME " ^ rvar
+ MQName -> "NAME " ^ rvar
+ | MQTheory -> "THEORY" ^ rvar
+ | MQTitle -> "TITLE" ^ rvar
+ | MQContributor -> "contributor" ^ rvar
+ | MQCreator -> "creator" ^ rvar
+ | MQPublisher -> "publisher" ^ rvar
+ | MQSubject -> "subject" ^ rvar
+ | MQDescription -> "description" ^ rvar
+ | MQDate -> "date" ^ rvar
+ | MQType -> "type" ^ rvar
+ | MQFormat -> "format" ^ rvar
+ | MQIdentifier -> "identifier" ^ rvar
+ | MQLanguage -> "language" ^ rvar
+ | MQRelation -> "relation" ^ rvar
+ | MQSource -> "source" ^ rvar
+ | MQCoverage -> "coverage" ^ rvar
+ | MQRights -> "rights" ^ rvar
+ | MQInstitution -> "institution" ^ rvar
+ | MQContact -> "contact" ^ rvar
+ | MQFirstVersion -> "firstversion" ^ rvar
+ | MQModified -> "modified" ^ rvar
)
| MQRVar rvar ->
rvar
(
match f with
MQName -> "NAME " ^ rvar
+ | MQTheory -> "THEORY" ^ rvar
+ | MQTitle -> "TITLE" ^ rvar
+ | MQContributor -> "contributor" ^ rvar
+ | MQCreator -> "creator" ^ rvar
+ | MQPublisher -> "publisher" ^ rvar
+ | MQSubject -> "subject" ^ rvar
+ | MQDescription -> "description" ^ rvar
+ | MQDate -> "date" ^ rvar
+ | MQType -> "type" ^ rvar
+ | MQFormat -> "format" ^ rvar
+ | MQIdentifier -> "identifier" ^ rvar
+ | MQLanguage -> "language" ^ rvar
+ | MQRelation -> "relation" ^ rvar
+ | MQSource -> "source" ^ rvar
+ | MQCoverage -> "coverage" ^ rvar
+ | MQRights -> "rights" ^ rvar
+ | MQInstitution -> "institution" ^ rvar
+ | MQContact -> "contact" ^ rvar
+ | MQFirstVersion -> "firstversion" ^ rvar
+ | MQModified -> "modified" ^ rvar
)
| MQRVar rvar ->
rvar
in
print_string (s1v ^ " = " ^ s2v)
;;
-
+*)
(*
* implementazione del comando SELECT
*)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val select_ex :
Mathql.mqrvar ->
Mathql.mqsvar list list -> Mathql.mqbool -> Mathql.mqsvar list list
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(*
+ * implementazione del comando SORTEDBY
+ *)
+
+open Mathql;;
+open Func;;
+open Utility;;
+
+(*
+ * implementazione del comando SORTEDBY
+ *)
+let sortedby_ex alist order afunc =
+ [List.hd alist]
+ @
+ List.map
+ (List.tl)
+ (Sort.list
+ (fun a b ->
+ match order with
+ MQAsc -> (List.hd a) < (List.hd b)
+ | MQDesc -> (List.hd a) > (List.hd b)
+ )
+ (List.map
+ (fun l -> [apply_func afunc (List.hd l)] @ l)
+ (List.tl alist)
+ )
+ )
+;;
+
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+val sortedby_ex :
+ string list list -> Mathql.mqorder -> Mathql.mqfunc -> string list list
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* implementazione del comando UNION
) (* match *)
;;
-(** TEST **)
-
-(*
-let h1 = ["retVal"; "a"; "b"];;
-let l1 = ["pippo"; "3"; "3"];;
-let l3 = ["pluto"; "7"; "8"]
-let r1 = [h1; l1; l3];;
-
-(*let h2 = ["retVal"; "b"; "c"];;
-let l2 = ["pippo"; "3"; "1"];;*)
-let h2 = ["retVal"; "a"; "b"];;
-let l2 = ["pippo"; "3"; "3"];;
-let r2 = [h2; l2];;
-
-List.map (fun l -> List.iter print_endline l) (xres_union (r1, r2));;
-*)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val union_ex : string list list -> string list list -> string list list
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* implementazione dei comandi USE/USED BY
*
* output: string list list; lista su cui e' stato eseguito il
* comando USE/USED BY
- *
- * TODO
- * USE e USED BY sono identici dal punto di vista algoritmico, per questo
- * sono stati accorpati in una sola funzione; stilisticamente, sarebbe meglio
- * avere due implementazioni distinte...
*)
let use_ex alist asvar usek =
let c = pgc () in
List.fold_left
(fun parziale xres ->
- let r1 = pgresult_to_string (c#exec
- ("select att0 from property where att2='" ^ usek ^ "'"))
- and r2 = pgresult_to_string (c#exec
- "select att0 from property where att2='position'")
- and r3 = pgresult_to_string (c#exec
- "select att0 from property where att2='occurrence'")
+ let r1 = helm_property_id usek
+ and r2 = helm_property_id "position"
+ and r3 = helm_property_id "occurrence"
in
- let res = c#exec (
- "select distinct t" ^ r3 ^ ".att1, t" ^ r2 ^ ".att1 " ^
+ let qq = "select distinct t" ^ r3 ^ ".att1, t" ^ r2 ^ ".att1 " ^
"from t" ^ r3 ^ ", t" ^ r2 ^ ", t" ^ r1 ^ " " ^
"where " ^ "t" ^ r1 ^ ".att0 = '" ^ (List.hd xres) ^ "' and t" ^ r1 ^
".att1 = t" ^ r2 ^ ".att0 and t" ^ r1 ^ ".att1 = t" ^ r3 ^
- ".att0")
+ ".att0"
in
+ (*let _ = print_endline ("use: " ^ qq) in*)
+ let res = c#exec qq in
parziale
@
if not (List.mem asvar (List.tl (List.hd alist))) then
(List.tl alist)
;;
-(** TEST **)
-
-(*
-let use_ex alist asvar =
- if (List.find_all asvar (List.tl (List.hd alist))) = [] then
- use_ex_nc alist asvar
- else
- use_ex_co alist asvar
-;;
-
-List.map
- (fun l ->
- let t =
- match xres with
- hd::tl -> (List.hd l)::tl
- | [] -> []
- in
- let hash = List.combine (List.hd alist) t in
- snd (set_assoc asvar (snd l) hash)
- )
- (List.find_all
- (fun l ->
- let currv =
- List.hd (List.tl l)
- and xresv =
- try (
- List.assoc asvar (List.combine (List.tl (List.hd alist)) (List.tl xres))
- ) with
- Not_found -> ""
- in
- xresv = "" or xresv = currv
- )
- res#get_list
- )
-;;
-*)
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
val use_ex : string list list -> string -> string -> string list list
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
(*
* funzioni di utilita' generale
*)
+open Dbconn;;
+
(*
* converte il risultato di una query in una lista di stringhe
*
* TODO
* verificare che l sia costruita come richiesto
*)
-let pgresult_to_string l = List.hd (List.hd l#get_list);;
+let pgresult_to_string l =
+ match l#get_list with
+ [] -> ""
+ | t -> List.hd (List.hd t)
+;;
(*
* parametri:
spila [] x v l
;;
-(** TEST **)
+(*
+ * parametri:
+ * p: string; nome della proprieta'
+ *
+ * output: string; id interno associato alla proprieta'
+ *)
+let helm_property_id p =
+ let c = pgc () in
+ let q1 = "select att0 from namespace where att1='http://www.cs.unibo.it/helm/schemas/mattone.rdf#'" in
+ let ns = pgresult_to_string (c#exec q1) in
+ let q2 = ("select att0 from property where att2='" ^ p ^ "' and att1=" ^ ns) in
+ let retval = pgresult_to_string (c#exec q2) in
+ (*let _ = print_endline ("utility:q2: " ^ q2 ^ " : " ^ retval) in*)
+ retval
+;;
(*
-let h = ["d";"b"];;
-let v = ["1";"2"];;
-let c = List.combine h v;;
+ * parametri:
+ * c: string; nome della classe
+ *
+ * output: string; id interno associato alla classe
+ *)
+let helm_class_id cl =
+ let c = pgc () in
+ let ns = pgresult_to_string (c#exec ("select att0 from namespace where att1='http://www.cs.unibo.it/helm/schemas/mattone.rdf#'")) in
+ pgresult_to_string (c#exec ("select att0 from class where att2='" ^ cl ^ "' and att1=" ^ ns))
+;;
-List.iter (fun (a,b) -> print_endline (a ^ ": " ^ b)) (set_assoc "a" "3" c);;
-*)
-val pgresult_to_string_list : < get_list : 'a list list; .. > -> 'a list
-val pgresult_to_string : < get_list : 'a list list; .. > -> 'a
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+val pgresult_to_string_list : < get_list : string list list; .. > -> string list
+val pgresult_to_string : < get_list : string list list; .. > -> string
val set_assoc : 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
+val helm_property_id: string -> string
+val helm_class_id: string -> string