done;
let l = Hashtbl.fold (fun k _ acc -> k::acc) h [] in
Tas.sort_of_list tree l
-
-(*28/01/2014
- parametres : tree l'arbre xml
- ls l'ensemble de noeuds
- a axis
- retour : l'ensemble de noeuds qui correspondent ॆ l'axe
-*)
+(* List.sort (compare_node tree) l *)
-let keep_elements t l = (*
- List.filter (fun n -> match Naive_tree.kind t n with
- | Element | Text | Document | Attribute -> true | _ -> false) l
- *) l
-let keep_attributs t l = (*
- List.filter (fun n -> match Naive_tree.kind t n with
- | Attribute ->true | _ -> false) *) l
let rec eval_axis tree ls a =
let open Xpath.Ast in
| Attribute -> let lfc = eval_move tree ls Firstchild in
let lc = eval_star tree lfc [Nextsibling] in
- keep_attributs tree lc
+ lc
| Child -> let lfc = eval_move tree ls Firstchild in
let lc = eval_star tree lfc [Nextsibling] in
- keep_elements tree lc
+ lc
| Descendant c -> let lfc = eval_move tree ls Firstchild in
let ls2 = eval_star tree lfc [Firstchild;Nextsibling] in
if not c then ls2
else List.merge (compare_node tree) ls2 ls
in
- keep_elements tree ldes
+ ldes
| FollowingSibling -> let lnexts = eval_move tree ls Nextsibling in
let lfs = eval_star tree lnexts [Nextsibling] in
- keep_elements tree lfs
+ lfs
| Parent -> let lprevs = eval_star tree ls [Prevsibling] in
let lp = eval_move tree lprevs Revfirstchild in
- keep_elements tree lp
+ lp
| Ancestor b -> let ls2 = eval_star tree ls [Revfirstchild;Prevsibling] in
let ls3 = eval_move tree ls2 Revfirstchild in
if not b then ls3
else List.merge (compare_node tree ) ls3 ls
in
- keep_elements tree lac
+ lac
| PrecedingSibling -> let ls2 = eval_star tree ls [Prevsibling] in
let lps = eval_move tree ls2 Prevsibling in
- keep_elements tree lps
+ lps
| Preceding -> let ls2 = eval_axis tree ls (Ancestor true) in
let ls3 = eval_axis tree ls2 PrecedingSibling in
let lp = eval_axis tree ls3 (Descendant true) in
- keep_elements tree lp
+ lp
| Following -> let ls2 = eval_axis tree ls (Ancestor true) in
let ls3 = eval_axis tree ls2 FollowingSibling in
let lf = eval_axis tree ls3 (Descendant true) in
- keep_elements tree lf
+ lf
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
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
exit 0