]> matita.cs.unibo.it Git - helm.git/commitdiff
added debugging code (disabled by default) that saves transformations
authorStefano Zacchiroli <zack@upsilon.cc>
Fri, 10 Jan 2003 11:35:12 +0000 (11:35 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Fri, 10 Jan 2003 11:35:12 +0000 (11:35 +0000)
intermediate results in /tmp

helm/uwobo/src/ocaml/uwobo_engine.ml

index 75e4669bf0d0ac251bd0d959c0cc8dc2930e7890..0bc5afcba4522a38abac2f0590a3acecee502ab3 100644 (file)
 open Printf;;
 open Uwobo_common;;
 
+  (** set this to true and uwobo will save transformation's intermediate results
+  in /tmp/uwobo_intermediate_<seqno>_<pid>.xml *)
+let save_intermediate_results = false;;
+
 exception Unsupported_property of string;;
 
 let xslNS = Gdome.domString "http://www.w3.org/1999/XSL/Transform"
@@ -86,6 +90,7 @@ let apply
     (* "p_" prefix means "processed" *)
   let (p_stylesheets, last_stylesheet) = styles#get keys in
   logger#log `Debug "Creating input document ...";
+  let intermediate_results_seqno = ref 0 in
   let result = (* Gdome.document *)
     List.fold_left
       (fun source (key, stylesheet) ->
@@ -100,6 +105,16 @@ let apply
               "Gdome_xslt.applyStylesheet params=%s"
               (String.concat ", " (List.map (fun (k,v) -> k^": "^v) params)));
           let res = Gdome_xslt.applyStylesheet ~source ~stylesheet ~params in
+          if save_intermediate_results then begin
+            let domImpl = Gdome.domImplementation () in
+            ignore
+              (domImpl#saveDocumentToFile
+                ~doc:res
+                ~name:(sprintf "/tmp/uwobo_intermediate_%d_%d.xml"
+                  !intermediate_results_seqno (Unix.getpid()))
+                ());
+            incr intermediate_results_seqno;
+          end;
           res
         with e -> raise (Uwobo_failure (Printexc.to_string e)))
       input