Supprimer des fonctions 'keep_elements' et 'keep_attributs'
[tatoo.git] / src / table_driver.ml
index 371dbdf..6ac6acb 100644 (file)
@@ -24,31 +24,25 @@ let main () =
       parse_xpath q) 
       !Table_options.queries
   in
+  let t1 = Unix.gettimeofday () in
   let query_tree_list =
     List.map (fun query -> compile_xpath query) queries
   in
-     List.iter ( fun q -> 
-      let res = eval_query_tree doc [ (Naive_tree.root doc) ] q in
-      print_string "<xml_result num=\"1\" >\n";
-      print_node_list doc res;
-      print_string "</xml_result>\n"
-    ) query_tree_list ;
+  let mini_qtree_list = 
+    List.map (fun qtree -> Query_tree.minimize_qtree qtree) query_tree_list 
+  in
+  List.iter ( fun q -> 
+    let res = eval_qtree doc [ (Naive_tree.root doc) ] q in
+    print_string "<xml_result num=\"1\" >\n";
+    print_node_list doc res;
+    print_string "</xml_result>\n";
+  ) mini_qtree_list ;
   
+  let t2 = Unix.gettimeofday () in
+  let t = (t2 -. t1) *. 1000. in
   let _ = if !Table_options.count then 
-       Format.fprintf Format.std_formatter "there are %i nodes\n" !Query_tree.compteur;
+       Format.fprintf Format.std_formatter "there are %i nodes\nit takes %fms\n" !Query_tree.compteur t;
   in
-  
- (* let output =
-    match !Options.output_file with
-      | None | Some "-" | Some "/dev/stdout" -> stdout
-      | Some f -> open_out f
-  in 
-    List.iter (fun query ->
-      Logger.msg `STATS "Query: %a " Xpath.Ast.print_path query) queries;
-    List.iter (fun query_tree ->
-      Logger.msg `STATS "@[Query_tree: @\n%a@]" print_query_tree Format.std_formatter query_tree) query_tree_list;
-  
-  *)
   exit 0
 
 
@@ -60,76 +54,4 @@ let () = main ()
 
 
 
-(*  let query = Xpath.Parser.parse
-            (Ulexing.from_utf8_string Sys.argv.(2))
-  in
-  Format.printf "La requete est: %a\n%!"
-    Xpath.Ast.print_path query; *)
-
- (* print_endline "Test 1 root.firstchild";
-  let c1 = eval_move doc [ (Naive_tree.root doc) ] Firstchild  in
-  print_node_list doc c1;
-  print_endline "Test 2 root.firstchild.firstchild";
-  let c2 = eval_move doc c1 Firstchild  in
-  print_node_list doc c2;
-  print_endline "Test 3 root.firstchild.firstchild.nextsibling";
-  let c3 = eval_move doc c2 Nextsibling in
-  print_node_list doc c3;
-  print_endline "Test 4 root.firstchild.firstchild.nextsibling.firstchild";
-  let c4 = eval_move doc c3  Firstchild in
-  print_node_list doc c4;
-  print_endline "Test 5 root.firstchild.firstchild.nextsibling.firstchild.ancestor false";
-  let c5 = eval_axis doc c4  (Ancestor false) in
-  print_node_list doc c5;
-  print_endline "Test 6";
-  let c6 = eval_move doc c5  Prevsibling in
-  print_node_list doc c6;
-  print_endline "Test 7";
-  let c7 = eval_move doc c6  Revfirstchild in
-  print_node_list doc c7;
-  print_endline "Test 8 Child [root]";
-  let c8 = eval_axis doc [Naive_tree.root doc]  Child in
-  print_node_list doc c8;
-  print_endline "Test 9 Descendant [b]";
-  let c9 = eval_axis doc c2  (Descendant false) in
-  print_node_list doc c9;
-  print_endline "Test 10 Descendant or self [b]";
-  let c10 = eval_axis doc c2  (Descendant true) in
-  print_node_list doc c10;
-  print_endline "Test 11 FollowingSibling [b]";
-  let c11 = eval_axis doc c2 FollowingSibling in
-  print_node_list doc c11;
-  print_endline "Test 12 Parent [b]";
-  let c12 = eval_axis doc c2  Parent in
-  print_node_list doc c12;
-  print_endline "Test 13  Ancestor or self [b]";
-  let c13 = eval_axis doc c2  (Ancestor true) in
-  print_node_list doc c13;
-  print_endline "Test 14 PrecdingSibling [b]";
-  let c14 = eval_axis doc c2  PrecedingSibling in
-  print_node_list doc c14;
-  print_endline "Test 15 preceding [b]";
-  let c15 = eval_axis doc c2  Preceding in
-  print_node_list doc c15;
-  print_endline "Test 16 Following [b]";
-  let c16 = eval_axis doc c2  Following in
-  print_node_list doc c16;
-  print_endline "Test 17 tag [b]";
-  let c17 = element_by_tag doc (QName.make "b") in
-  print_node_list doc c17;
-  print_endline "Test 18 all nodes";
-  let c18 = all_nodes doc in
-  print_node_list doc c18;
-  print_endline "Test 19 compile_xpath"; *)
-
-
- (*Format.printf "Le document contient: %i noeuds\n%!" (Naive_tree.size doc);
-  let c19 = compile_xpath (parse_xpath "/child::a[child::b or not(following::]") in
-  Format.printf ">> %a\n%!" print_query_tree c19;
-  print_endline "Test 20 eval_query_tree";
-  let res = eval_query_tree doc [ (Naive_tree.root doc) ] c19 in
-  print_node_list doc res;
-  print_endline "Fin";*)
-
-