Test cases from XPath-PT, script.
[tatoo.git] / src / solve.ml
index 5074ae0..6e25db2 100644 (file)
@@ -15,7 +15,8 @@
 
 
 (** use: [./test xml_file -f XPath_queries_file]
-    one query per line [XPath_querie_file]
+    one query per line [XPath_querie_file], output
+    a solution per line.
 *)
 
 open Format
@@ -24,7 +25,6 @@ let doc () =
   let fd = open_in Sys.argv.(1) in
   let d = Tree.load_xml_file fd in
   close_in fd;
-  fprintf err_formatter "Parse Tree OK ! ";
   d
 
 
@@ -38,9 +38,8 @@ let query () =
           with _ -> list in
         let list = list_qu fq [] in
         close_in fq;
-        fprintf err_formatter "Parse query OK !\n %!";
         list
-  else failwith "Use -f"
+  else failwith "Use ./test xml_file -f XPath_queries_file"
 
 let compute_run doc query = 
   let run = Run.compute doc query in
@@ -50,9 +49,6 @@ let () =
   let flag  = Array.length Sys.argv = 5 in
   Format.pp_set_margin err_formatter 80;
   let doc = doc () in
-  output_string stderr "##### Doc with positions #####\n";
-  Tree.print_xml_preorder stderr doc (Tree.root doc);
-  output_string stderr "\n";
   let queries = query () in
   let rec print_selec fmt l = match l with
     | [x] -> fprintf fmt "%s" (string_of_int x)
@@ -64,8 +60,11 @@ let () =
       let asta = Compil.trans query in
       let selected_nodes = Run.selected_nodes doc asta in
       let run = compute_run doc asta in
-      fprintf err_formatter "\n  ### Query: %a"
-        XPath.Ast.print query;      
+      if flag
+      then
+        fprintf err_formatter "  ### Query: %a"
+          XPath.Ast.print query
+      else ();
       fprintf err_formatter "@.  ### Selected nodes: {%a}@."
         print_selec selected_nodes;
       if flag
@@ -74,7 +73,6 @@ let () =
         Run.print err_formatter run;
       end
       else ();
-      let asta = Asta.empty in
       solve_queries tl in
   solve_queries queries;
   exit 0