]> matita.cs.unibo.it Git - helm.git/blob - helm/uwobo/src/ocaml/uwobo_engine.ml
snapshot Wed, 27 Nov 2002 18:10:57 +0100
[helm.git] / helm / uwobo / src / ocaml / uwobo_engine.ml
1
2 (* Copyright (C) 2002, HELM Team.
3  * 
4  * This file is part of HELM, an Hypertextual, Electronic
5  * Library of Mathematics, developed at the Computer Science
6  * Department, University of Bologna, Italy.
7  * 
8  * HELM is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * HELM is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with HELM; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21  * MA  02111-1307, USA.
22  * 
23  * For details, see the HELM World-Wide-Web page,
24  * http://cs.unibo.it/helm/.
25  *)
26
27 open Printf;;
28 open Uwobo_common;;
29
30 let dump_args keys params props =
31   (sprintf "
32 <h1>Uwobo_engine.apply: not yet implemented!</h1>
33 Keys: %s<br />
34 Parameters:<br />
35 %s
36 Props: %s<br />
37 "
38     (String.concat ", " keys)
39     (String.concat
40       "<br />\n"
41       (List.map
42         (fun key ->
43           (sprintf
44             "Key: %s, Params: %s"
45             key
46             (String.concat
47               ", "
48               (List.map
49                 (fun (key,value) -> sprintf "%s:%s" key value)
50                 (params key)))))
51         keys))
52     (String.concat
53       ", "
54       (List.map (fun (key,value) -> sprintf "%s:%s" key value) props)))
55
56   (* TODO add global mutex, stylesheets are freezed at the request moment *)
57 let apply
58   ~(logger: Uwobo_logger.processingLogger)
59   ~(styles: Uwobo_styles.styles)
60   ~keys ~params ~props ~input =
61   let stylesheets = styles#get keys in
62   logger#log (dump_args keys params props);
63   logger#log "Creating input document ...";
64   List.fold_left
65     (fun source (key, stylesheet) ->
66       logger#log (sprintf "Applying stylesheet %s ..." key);
67       try
68         Gdome_xslt.applyStylesheet ~source ~stylesheet ~params:(params key)
69       with e -> raise (Uwobo_failure (Printexc.to_string e)))
70     input
71     stylesheets
72