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
33 let res = eval_query_tree doc [ (Naive_tree.root doc) ] q in
34 print_node_list doc res;
35 Format.printf "---------------Fin %i\n!" !cpt;
40 match !Options.output_file with
41 | None | Some "-" | Some "/dev/stdout" -> stdout
42 | Some f -> open_out f
44 List.iter (fun query ->
45 Logger.msg `STATS "Query: %a " Xpath.Ast.print_path query) queries;
46 List.iter (fun query_tree ->
47 Logger.msg `STATS "@[Query_tree: @\n%a@]" print_query_tree Format.std_formatter query_tree) query_tree_list;
61 (* let query = Xpath.Parser.parse
62 (Ulexing.from_utf8_string Sys.argv.(2))
64 Format.printf "La requete est: %a\n%!"
65 Xpath.Ast.print_path query; *)
67 (* print_endline "Test 1 root.firstchild";
68 let c1 = eval_move doc [ (Naive_tree.root doc) ] Firstchild in
69 print_node_list doc c1;
70 print_endline "Test 2 root.firstchild.firstchild";
71 let c2 = eval_move doc c1 Firstchild in
72 print_node_list doc c2;
73 print_endline "Test 3 root.firstchild.firstchild.nextsibling";
74 let c3 = eval_move doc c2 Nextsibling in
75 print_node_list doc c3;
76 print_endline "Test 4 root.firstchild.firstchild.nextsibling.firstchild";
77 let c4 = eval_move doc c3 Firstchild in
78 print_node_list doc c4;
79 print_endline "Test 5 root.firstchild.firstchild.nextsibling.firstchild.ancestor false";
80 let c5 = eval_axis doc c4 (Ancestor false) in
81 print_node_list doc c5;
82 print_endline "Test 6";
83 let c6 = eval_move doc c5 Prevsibling in
84 print_node_list doc c6;
85 print_endline "Test 7";
86 let c7 = eval_move doc c6 Revfirstchild in
87 print_node_list doc c7;
88 print_endline "Test 8 Child [root]";
89 let c8 = eval_axis doc [Naive_tree.root doc] Child in
90 print_node_list doc c8;
91 print_endline "Test 9 Descendant [b]";
92 let c9 = eval_axis doc c2 (Descendant false) in
93 print_node_list doc c9;
94 print_endline "Test 10 Descendant or self [b]";
95 let c10 = eval_axis doc c2 (Descendant true) in
96 print_node_list doc c10;
97 print_endline "Test 11 FollowingSibling [b]";
98 let c11 = eval_axis doc c2 FollowingSibling in
99 print_node_list doc c11;
100 print_endline "Test 12 Parent [b]";
101 let c12 = eval_axis doc c2 Parent in
102 print_node_list doc c12;
103 print_endline "Test 13 Ancestor or self [b]";
104 let c13 = eval_axis doc c2 (Ancestor true) in
105 print_node_list doc c13;
106 print_endline "Test 14 PrecdingSibling [b]";
107 let c14 = eval_axis doc c2 PrecedingSibling in
108 print_node_list doc c14;
109 print_endline "Test 15 preceding [b]";
110 let c15 = eval_axis doc c2 Preceding in
111 print_node_list doc c15;
112 print_endline "Test 16 Following [b]";
113 let c16 = eval_axis doc c2 Following in
114 print_node_list doc c16;
115 print_endline "Test 17 tag [b]";
116 let c17 = element_by_tag doc (QName.make "b") in
117 print_node_list doc c17;
118 print_endline "Test 18 all nodes";
119 let c18 = all_nodes doc in
120 print_node_list doc c18;
121 print_endline "Test 19 compile_xpath"; *)
124 (*Format.printf "Le document contient: %i noeuds\n%!" (Naive_tree.size doc);
125 let c19 = compile_xpath (parse_xpath "/child::a[child::b or not(following::]") in
126 Format.printf ">> %a\n%!" print_query_tree c19;
127 print_endline "Test 20 eval_query_tree";
128 let res = eval_query_tree doc [ (Naive_tree.root doc) ] c19 in
129 print_node_list doc res;
130 print_endline "Fin";*)