- match a.node with
- | Node(_) ->
- let value =
- match (left a).node with
- | Nil -> ""
- | _ -> string (left(left a))
- in
- output_char outc ' ';
- output_string outc (Tag.to_string (tag a));
- output_string outc "=\"";
- output_string outc value;
- output_char outc '"';
- loop_attributes (right a)
- | _ -> ()
- in
- loop ~print_right:false t
-
-
- let print_xml_fast outc t =
- if Tag.to_string (tag t) = "" then
- print_xml_fast outc (first_child t)
- else print_xml_fast outc t
-
- let traversal t = Tree.traversal t.doc
- let full_traversal t =
- let rec aux n =
- match n.node with
- | Nil -> ()
- | String i -> () (*ignore(Text.get_text t.text i) *)
- | Node(_) ->
- (* tag_id n; *)
- aux (first_child n);
- aux (next_sibling n)
- in aux t
- end
-
-end
-
-
-
-
-
-module DEBUGTREE
- = struct
-
- let _timings = Hashtbl.create 107
-
-
- let time _ref f arg =
- let t1 = Unix.gettimeofday () in
- let r = f arg in
- let t2 = Unix.gettimeofday () in
- let t = (1000. *.(t2 -. t1)) in
-
- let (time,count) = try
- Hashtbl.find _timings _ref
- with
- | Not_found -> 0.,0
- in
- let time = time+. t
- and count = count + 1
- in
- Hashtbl.replace _timings _ref (time,count);r
-
- include XML.Binary
-
-
- let first_child_ doc node =
- time ("XMLTree.FirstChild()") (XML.Tree.first_child doc) node
- let next_sibling_ doc node =
- time ("XMLTree.NextSibling()") (XML.Tree.next_sibling doc) node
-
- let is_empty_ text node =
- time ("TextCollection.IsEmpty()") (XML.Text.is_empty text) node
-
- let prev_text_ doc node =
- time ("XMLTree.PrevText()") (XML.Tree.prev_text doc) node
-
- let my_text_ doc node =
- time ("XMLTree.MyText()") (XML.Tree.my_text doc) node
-
- let next_text_ doc node =
- time ("XMLTree.NextText()") (XML.Tree.next_text doc) node
-
- let is_leaf_ doc node =
- time ("XMLTree.IsLeaf()") (XML.Tree.is_leaf doc ) node
-
- let node_xml_id_ doc node =
- time ("XMLTree.NodeXMLId()") (XML.Tree.node_xml_id doc ) node
-
- let text_xml_id_ doc node =
- time ("XMLTree.TextXMLId()") (XML.Tree.text_xml_id doc ) node
-
-
- let first_child n =
- let node' =
- match n.node with
- | Node (NC t) when is_leaf_ n.doc t ->
- let txt = my_text_ n.doc t in
- if is_empty_ n.text txt
- then Nil
- else Node(SC (txt,XML.Tree.nil))
- | Node (NC t) ->
- let fs = first_child_ n.doc t in
- let txt = prev_text_ n.doc fs in
- if is_empty_ n.text txt
- then norm fs
- else Node (SC (txt, fs))
- | Node(SC (i,_)) -> String i
- | Nil | String _ -> failwith "first_child"
- in
- { n with node = node'}
-
-
- let next_sibling n =
- let node' =
- match n.node with
- | Node (SC (_,ns)) -> norm ns
- | Node(NC t) ->
- let ns = next_sibling_ n.doc t in
- let txt = next_text_ n.doc t in
- if is_empty_ n.text txt
- then norm ns
- else Node (SC (txt, ns))
- | Nil | String _ -> failwith "next_sibling"