6 Xpath.Parser.parse (Ulexing.from_utf8_string p)
9 let () = Table_options.parse () in
11 let fd, close_fd = match !Table_options.input_file with
12 None | Some "-" | Some "/dev/stdin" ->stdin,ignore (*qu'est-ce que c'est ignore?????*)
14 let fd = open_in input in fd, fun() -> close_in fd
16 (*let inc = open_in Sys.argv.(1) in*)
17 let doc = Naive_tree.load_xml_file fd in
18 close_fd(); (*ca sert a fermer fd????*)
24 !Table_options.queries
27 List.map (fun query -> compile_xpath query) queries
30 let res = eval_query_tree doc [ (Naive_tree.root doc) ] q in
31 print_string "<xml_result num=\"1\" >\n";
32 print_node_list doc res;
33 print_string "</xml_result>\n"
37 match !Options.output_file with
38 | None | Some "-" | Some "/dev/stdout" -> stdout
39 | Some f -> open_out f
41 List.iter (fun query ->
42 Logger.msg `STATS "Query: %a " Xpath.Ast.print_path query) queries;
43 List.iter (fun query_tree ->
44 Logger.msg `STATS "@[Query_tree: @\n%a@]" print_query_tree Format.std_formatter query_tree) query_tree_list;
58 (* let query = Xpath.Parser.parse
59 (Ulexing.from_utf8_string Sys.argv.(2))
61 Format.printf "La requete est: %a\n%!"
62 Xpath.Ast.print_path query; *)
64 (* print_endline "Test 1 root.firstchild";
65 let c1 = eval_move doc [ (Naive_tree.root doc) ] Firstchild in
66 print_node_list doc c1;
67 print_endline "Test 2 root.firstchild.firstchild";
68 let c2 = eval_move doc c1 Firstchild in
69 print_node_list doc c2;
70 print_endline "Test 3 root.firstchild.firstchild.nextsibling";
71 let c3 = eval_move doc c2 Nextsibling in
72 print_node_list doc c3;
73 print_endline "Test 4 root.firstchild.firstchild.nextsibling.firstchild";
74 let c4 = eval_move doc c3 Firstchild in
75 print_node_list doc c4;
76 print_endline "Test 5 root.firstchild.firstchild.nextsibling.firstchild.ancestor false";
77 let c5 = eval_axis doc c4 (Ancestor false) in
78 print_node_list doc c5;
79 print_endline "Test 6";
80 let c6 = eval_move doc c5 Prevsibling in
81 print_node_list doc c6;
82 print_endline "Test 7";
83 let c7 = eval_move doc c6 Revfirstchild in
84 print_node_list doc c7;
85 print_endline "Test 8 Child [root]";
86 let c8 = eval_axis doc [Naive_tree.root doc] Child in
87 print_node_list doc c8;
88 print_endline "Test 9 Descendant [b]";
89 let c9 = eval_axis doc c2 (Descendant false) in
90 print_node_list doc c9;
91 print_endline "Test 10 Descendant or self [b]";
92 let c10 = eval_axis doc c2 (Descendant true) in
93 print_node_list doc c10;
94 print_endline "Test 11 FollowingSibling [b]";
95 let c11 = eval_axis doc c2 FollowingSibling in
96 print_node_list doc c11;
97 print_endline "Test 12 Parent [b]";
98 let c12 = eval_axis doc c2 Parent in
99 print_node_list doc c12;
100 print_endline "Test 13 Ancestor or self [b]";
101 let c13 = eval_axis doc c2 (Ancestor true) in
102 print_node_list doc c13;
103 print_endline "Test 14 PrecdingSibling [b]";
104 let c14 = eval_axis doc c2 PrecedingSibling in
105 print_node_list doc c14;
106 print_endline "Test 15 preceding [b]";
107 let c15 = eval_axis doc c2 Preceding in
108 print_node_list doc c15;
109 print_endline "Test 16 Following [b]";
110 let c16 = eval_axis doc c2 Following in
111 print_node_list doc c16;
112 print_endline "Test 17 tag [b]";
113 let c17 = element_by_tag doc (QName.make "b") in
114 print_node_list doc c17;
115 print_endline "Test 18 all nodes";
116 let c18 = all_nodes doc in
117 print_node_list doc c18;
118 print_endline "Test 19 compile_xpath"; *)
121 (*Format.printf "Le document contient: %i noeuds\n%!" (Naive_tree.size doc);
122 let c19 = compile_xpath (parse_xpath "/child::a[child::b or not(following::]") in
123 Format.printf ">> %a\n%!" print_query_tree c19;
124 print_endline "Test 20 eval_query_tree";
125 let res = eval_query_tree doc [ (Naive_tree.root doc) ] c19 in
126 print_node_list doc res;
127 print_endline "Fin";*)