3 * Stefano Zacchiroli <zack@cs.unibo.it>
4 * for the HELM Team http://helm.cs.unibo.it/
6 * This file is part of HELM, an Hypertextual, Electronic
7 * Library of Mathematics, developed at the Computer Science
8 * Department, University of Bologna, Italy.
10 * HELM is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * HELM is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with HELM; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * For details, see the HELM World-Wide-Web page,
26 * http://helm.cs.unibo.it/
31 exception Uwobo_failure of string ;;
33 let uwobo_namespace = "http://helm.cs.unibo.it/uwobo" ;;
34 let xsl_namespace = "http://helm.cs.unibo.it/uwobo" ;;
36 let supported_properties = [
37 "cdata-section-elements";
44 "omit-xml-declaration";
49 let is_supported_property name = List.mem name supported_properties
51 let version = "0.2.1" ;;
58 <title>UWOBO's help message</title>
61 <h1>UWOBO (version: %s)</h1>
66 Usage: <kbd>http://hostname:uwoboport/</kbd><em>command</em>
72 <b><kbd>help</kbd></b><br />
73 display this help message
76 <b><kbd>newsession?port=p</kbd></b><br />
77 starts a new daemon on a given port <em>p</em>
80 <b><kbd>kill</kbd></b><br />
81 kills the daemon. The log file is mantained.
84 <b><kbd>add?bind=key,uri[&bind=key,uri[&...]]</kbd></b><br />
85 load a new stylesheet, specified by <em>uri</em>, and bind it to key
89 <b><kbd>remove?keys=[key1,key2,...]</kbd></b><br />
90 unload stylesheets specified by <em>key1, key2, ...</em> or all
91 stylesheets if no key was given
94 <b><kbd>reload?keys=[key1,key2,...]</kbd></b><br />
95 reload stylesheets specified by <em>key1, key2, ...</em> or all
96 stylesheets if no key was given
99 <b><kbd>list</kbd></b><br />
100 return a list of loaded stylesheets
103 <b><kbd>apply?xmluri=uri&keys=key1,key2,...[&errormode={ignore|comment|embed}][&debugmode={ignore|comment|embed}][¶m.name=value[¶m.name=value[&...]]][¶m.key.name=value[¶m.key.name=value[&...]]][&prop.name[=value][&prop.name[=value][&...]]]</kbd></b><br />
104 apply a chain of stylesheets, specified by <em>key1, key2, ...</em>, to an
105 input document, specified by <em>uri</em>.<br />
106 Error and debugging modes could be ste to three different values.
107 <em>ignore</em> means that LibXSLT messages are ignored; <em>comment</em>
108 meanst that LibXSLT messages are embedded in the result document inside an
109 XML like comment; <em>embed</em> means that LibXSLT messages are embedded
110 at the beginning of the result document (as childs of the root node) in
111 XML elements in the UWOBO namespace<br />
112 Additional parameters can be set for each stylesheet application: global
113 parameters (i.e. parameters passed to all stylesheets) are set using
114 <em>param.name=value</em> syntax, per stylesheet parameters are set using
115 <em>param.key.name=value</em> where <em>key</em> is the key of a loaded
117 Properties of the final chain output can be set too: valueless properties
118 can be set using <em>prop.name</em> syntax, others can be set using
119 <em>prop.name=value</em> syntax.<br />
120 Current supported properties are: %s.
126 (String.concat ", " supported_properties) (* supported properties *)
131 "<html><body><span style=\"color:red\">Error: %s</span>%s</body></html>"
133 let return_error msg ?(body = "") outchan =
134 Http_daemon.respond ~body:(pp_error msg body) outchan;;
135 let bad_request body outchan =
136 Http_daemon.respond_error ~code:400 ~body outchan
139 (** {2 LibXSLT logging} *)
142 | LibXsltErrorMsg of string
143 | LibXsltDebugMsg of string
146 let string_of_xslt_msg = function
147 | LibXsltErrorMsg msg -> "LibXSLT ERROR: " ^ msg
148 | LibXsltDebugMsg msg -> "LibXSLT DEBUG: " ^ msg
157 class libXsltLogger =
158 let is_libxslt_error = function LibXsltErrorMsg _ -> true | _ -> false in
159 let is_libxslt_debug = function LibXsltDebugMsg _ -> true | _ -> false in
160 let flatten_libxslt_msg = function
161 | LibXsltErrorMsg msg -> msg
162 | LibXsltDebugMsg msg -> msg
167 Gdome_xslt.setErrorCallback
168 (Some (fun msg -> self#appendMsg (LibXsltErrorMsg msg)));
169 Gdome_xslt.setDebugCallback
170 (Some (fun msg -> self#appendMsg (LibXsltDebugMsg msg)))
172 val mutable libXsltMsgs = [] (** libxslt's error and debugging messages *)
174 (* libxslt's error and debugging messages handling *)
176 method private appendMsg msg = libXsltMsgs <- msg :: libXsltMsgs
178 method clearMsgs = libXsltMsgs <- []
179 method clearErrorMsgs =
180 libXsltMsgs <- List.filter is_libxslt_debug libXsltMsgs
181 method clearDebugMsgs =
182 libXsltMsgs <- List.filter is_libxslt_error libXsltMsgs
184 method msgs = libXsltMsgs
186 List.map flatten_libxslt_msg (List.filter is_libxslt_error libXsltMsgs)
188 List.map flatten_libxslt_msg (List.filter is_libxslt_debug libXsltMsgs)