]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/uwobo/src/ocaml/uwobo.ml
snapshot Wed, 27 Nov 2002 14:47:14 +0100
[helm.git] / helm / uwobo / src / ocaml / uwobo.ml
index 142fddd7d1da846cde9dff35270de816001df36f..625455469527cd05e696ba0bc73107a9b95b633d 100644 (file)
@@ -88,6 +88,29 @@ let callback req outchan =
           keys);
     Http_daemon.respond ~body:log#asHtml outchan
   in
+  let parse_apply_params =  (* parse parameters for '/apply' action *)
+    let is_global_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){1}$" x in
+    let is_local_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){2}$" x in
+    let is_property x = Pcre.pmatch ~pat:"^prop\\.[^.]+$" x in
+    List.fold_left
+      (fun (old_params, old_properties) (name, value) ->
+        match name with
+        | name when is_global_param name ->
+            let name = Pcre.replace ~pat:"^param\\." name in
+            ((fun x -> (old_params x) @ [name, value]), old_properties)
+        | name when is_local_param name ->
+            let pieces = Pcre.extract ~pat:"^param\\.([^.]+)\\.(.*)" name in
+            let (key, name) = (pieces.(1), pieces.(2)) in
+            ((function
+              | x when x = key -> [name, value] @ (old_params x)
+              | x -> old_params x),
+             old_properties)
+        | name when is_property name ->
+            let name = Pcre.replace ~pat:"^prop\\." name in
+            (old_params, ((name, value) :: old_properties))
+        | _ -> (old_params, old_properties))
+      ((fun _ -> []), []) (* no parameters, no properties *)
+  in
   try
     syslogger#log `Debug (sprintf "Received request: %s" req#path);
     (match req#path with
@@ -124,6 +147,7 @@ let callback req outchan =
         act_on_keys
           req styles outchan
           styles#reload (fun () -> styles#reloadAll) "reloading"
+
     | "/apply" ->
         (let logger = new Uwobo_logger.processingLogger () in
         let xmluri = req#param "xmluri" in
@@ -131,31 +155,7 @@ let callback req outchan =
         (* notation: "local" parameters are those defined on a per-stylesheet
         pasis (i.e. param.key.param=value), "global" parameters are those
         defined for all stylesheets (i.e. param.param=value) *)
-        let is_global_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){1}$" x in
-        let is_local_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){2}$" x in
-        let is_property x = Pcre.pmatch ~pat:"^prop\\.[^.]+$" x in
-        let (params, props) =
-          List.fold_left
-            (fun (old_params, old_properties) (name, value) ->
-              match name with
-              | name when is_global_param name ->
-                  let name = Pcre.replace ~pat:"^param\\." name in
-                  ((fun x -> (old_params x) @ [name, value]),
-                   old_properties)
-              | name when is_local_param name ->
-                  let pieces = Pcre.extract ~pat:"^param\\.([^.]+)\\.(.*)" name in
-                  let (key, name) = (pieces.(1), pieces.(2)) in
-                  ((function
-                    | x when x = key -> [name, value] @ (old_params x)
-                    | x -> old_params x),
-                   old_properties)
-              | name when is_property name ->
-                  let name = Pcre.replace ~pat:"^prop\\." name in
-                  (old_params, ((name, value) :: old_properties))
-              | _ -> (old_params, old_properties))
-            ((fun _ -> []), []) (* no parameters, no properties *)
-            req#params
-        in
+        let (params, props) = parse_apply_params req#params in
         syslogger#log `Debug (sprintf "Parsing input document %s ..." xmluri);
         let input = styles#domImpl#createDocumentFromURI ~uri:xmluri () in
         let output =