Add option -nw control the wrapping of results in an <xml_result/> node.
[SXSI/xpathcomp.git] / src / main.ml
index 0fbebad..2030452 100644 (file)
@@ -24,11 +24,11 @@ let mk_runtime run auto doc arg count print outfile =
     if !Options.do_perf then start_perf ();
     let r = time ~count:!Options.repeat ~msg:"Execution time" (run auto doc) arg in
     if !Options.do_perf then stop_perf ();
-    Logger.print Format.err_formatter "Number of results: %i@\n" (count r);
+    Logger.verbose Format.err_formatter "Number of results: %i@\n" (count r);
     match outfile with
        None -> ()
       | Some file ->
-       time ~count:1 ~msg:"Serialization time" (print file doc) r
+       time ~count:1 ~msg:"Serialization time" (print file !Options.no_wrap_results doc) r
 ;;
 
 let main v query_string output =
@@ -37,10 +37,8 @@ let main v query_string output =
   let query =
     time ~msg:"Parsing query" XPath.parse query_string
   in
-  if !Options.verbose then begin
-    Logger.print Format.err_formatter "Parsed query:@\n%a@\n"
-      XPath.Ast.print query;
-  end;
+  Logger.verbose Format.err_formatter "Parsed query:%a@\n"
+    XPath.Ast.print query;
   let auto, bu_info =
     time ~msg:"Compiling query" Compile.compile query
   in
@@ -55,7 +53,7 @@ let main v query_string output =
       if !Options.count_only then
         let module R = ResJIT.Count in
         let module M = Runtime.Make(R) in
-        mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize None
+        mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Options.output_file
       else
         let module R = ResJIT.Mat in
         let module M = Runtime.Make(R) in
@@ -65,14 +63,14 @@ let main v query_string output =
       (* run the query top_down *)
 
       if !Options.bottom_up then
-        Logger.print Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
+        Logger.verbose Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
       if !Options.count_only then
         let module R = ResJIT.Count in
         let module M = Runtime.Make(R) in
         if !Options.twopass then
           mk_runtime M.twopass_top_down_run auto v Tree.root R.NS.length R.NS.serialize None
         else
-          mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize None
+          mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize !Options.output_file
       else
         let module R = ResJIT.Mat in
         let module M = Runtime.Make(R) in
@@ -113,8 +111,7 @@ let _ =
        v
     in
     main document !Options.query !Options.output_file;
-    if !Options.verbose then
-      Logger.print Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
+    Logger.verbose Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
     Gc.full_major();
     Profile.summary Format.err_formatter
   with