]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/applyStylesheets.ml
first moogle template checkin
[helm.git] / helm / ocaml / cic_transformations / applyStylesheets.ml
1 (* Copyright (C) 2000-2002, 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 (*                               PROJECT HELM                                 *)
29 (*                                                                            *)
30 (*                Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>               *)
31 (*                                 30/01/2002                                 *)
32 (*                                                                            *)
33 (*                                                                            *)
34 (******************************************************************************)
35
36 (** stylesheets and parameters list **)
37
38 let parseStyle name =
39  let style =
40   Misc.domImpl#createDocumentFromURI
41    (* ~uri:("http://phd.cs.unibo.it:8081/getxslt?uri=" ^ name) ?mode:None *)
42    ~uri:("styles/" ^ name) ()
43  in
44   Gdome_xslt.processStylesheet style
45 ;;
46
47 let parseStyles () =
48  parseStyle "drop_coercions.xsl",
49  parseStyle "objtheorycontent.xsl",
50  parseStyle "content_to_html.xsl",
51  parseStyle "link.xsl",
52  parseStyle "rootcontent.xsl",
53  parseStyle "genmmlid.xsl",
54  parseStyle "annotatedpres.xsl"
55 ;;
56
57 let (d_c,tc1,hc2,l,c1,g,c2) =
58  let (d_c,tc1,hc2,l,c1,g,c2) = parseStyles () in
59   ref d_c, ref tc1, ref hc2, ref l, ref c1, ref g, ref c2
60 ;;
61
62 let reload_stylesheets () =
63  let (d_c',tc1',hc2',l',c1',g',c2') = parseStyles () in
64   d_c := d_c';
65   tc1 := tc1';
66   hc2 := hc2';
67   l   := l'  ;
68   c1  := c1' ;
69   g   := g'  ;
70   c2  := c2'
71 ;;
72
73
74 let mml_styles = [d_c ; c1 ; g ; c2 ; l];;
75 let mml_args ~explode_all =
76  ("explodeall",(if explode_all then "true()" else "false()"))::
77   ["processorURL", "'" ^ Helm_registry.get "uwobo.url" ^ "'" ;
78    "getterURL", "'" ^ Helm_registry.get "getter.url" ^ "'" ;
79    "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
80    "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
81    "UNICODEvsSYMBOL", "'symbol'" ;
82    "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
83    "encoding", "'iso-8859-1'" ;
84    "media-type", "'text/html'" ;
85    "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
86    "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
87    "naturalLanguage", "'yes'" ;
88    "annotations", "'no'" ;
89    "URLs_or_URIs", "'URIs'" ;
90    "topurl", "'http://phd.cs.unibo.it/helm'" ;
91    "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
92 ;;
93
94 let sequent_styles = [d_c ; c1 ; g ; c2 ; l];;
95 let sequent_args () =
96  ["processorURL", "'" ^ Helm_registry.get "uwobo.url" ^ "'" ;
97   "getterURL", "'" ^ Helm_registry.get "getter.url" ^ "'" ;
98   "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
99   "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
100   "UNICODEvsSYMBOL", "'symbol'" ;
101   "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
102   "encoding", "'iso-8859-1'" ;
103   "media-type", "'text/html'" ;
104   "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
105   "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
106   "naturalLanguage", "'no'" ;
107   "annotations", "'no'" ;
108   "explodeall", "true()" ;
109   "URLs_or_URIs", "'URIs'" ;
110   "topurl", "'http://phd.cs.unibo.it/helm'" ;
111   "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
112 ;;
113
114 (** Stylesheets application **)
115
116 let apply_stylesheets input styles args =
117  List.fold_left (fun i style -> Gdome_xslt.applyStylesheet i !style args)
118   input styles
119 ;;
120
121 let apply_proof_stylesheets proof_doc ~explode_all =
122  apply_stylesheets proof_doc mml_styles (mml_args ~explode_all)
123 ;;
124
125 let apply_sequent_stylesheets sequent_doc =
126  apply_stylesheets sequent_doc sequent_styles (sequent_args ())
127 ;;
128
129 (** Utility functions to map objects to MathML Presentation **)
130
131 (*CSC: the getter should handle the innertypes, not the FS *)
132
133 let innertypesfile () = Helm_registry.get "gtoplevel.inner_types_file";;
134 let constanttypefile () = Helm_registry.get "gtoplevel.constant_type_file";;
135
136 let mml_of_cic_sequent metasenv sequent =
137  let sequent_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
138   SequentPp.XmlPp.print_sequent metasenv sequent in
139  let sequent_doc =
140   Xml2Gdome.document_of_xml Misc.domImpl sequent_gdome in
141  let sequent_mml = apply_sequent_stylesheets sequent_doc in
142   sequent_mml,(ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
143 ;;
144
145 let
146  mml_of_cic_object ~explode_all uri annobj ids_to_inner_sorts ids_to_inner_types
147 =
148 (*CSC: ????????????????? *)
149  let xml, bodyxml =
150   Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:true
151    annobj 
152  in
153  let xmlinnertypes =
154   Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
155    ~ask_dtd_to_the_getter:true
156  in
157   let input =
158    match bodyxml with
159       None -> Xml2Gdome.document_of_xml Misc.domImpl xml
160     | Some bodyxml' ->
161        Xml.pp xml (Some (constanttypefile ())) ;
162        Xml2Gdome.document_of_xml Misc.domImpl bodyxml'
163   in
164 (*CSC: We save the innertypes to disk so that we can retrieve them in the  *)
165 (*CSC: stylesheet. This DOES NOT work when UWOBO and/or the getter are not *)
166 (*CSC: local.                                                              *)
167    Xml.pp xmlinnertypes (Some (innertypesfile ())) ;
168    let output = apply_proof_stylesheets input ~explode_all in
169     output
170 ;;
171
172
173
174
175