- type t = { doc : doc;
- node : descr }
-
- let dump { doc=t } = Tree.print_skel t
- open Tree
- let node_of_t t = { doc= t; node= Node(`Node (root t)) }
-
-
- let parse_xml_uri str = node_of_t (parse_xml_uri str)
- let parse_xml_string str = node_of_t (parse_xml_string str)
-
- let compare a b = match a.node,b.node with
- | Node(`Node i),Node(`Node j) -> compare i j
- | _, Node(`Node( _ )) -> 1
- | Node(`String (i,_)),Node(`String (j,_)) -> compare i j
- | Node(`Node( _ )),Node(`String (_,_)) -> -1
- | _, Node(`String (_,_)) -> 1
- | String i, String j -> compare i j
- | Node _ , String _ -> -1
- | _ , String _ -> 1
- | Nil, Nil -> 0
- | _,Nil -> -1
-
- let equal a b = (compare a b) == 0
-
- let string t = match t.node with
- | String i -> Text.get_text (text_collection t.doc) i
- | _ -> assert false
-
- let norm (n : [`Tree ] node ) = if is_nil n then Nil else Node (`Node n)
-
- let descr t = t.node
-
- let first_child n =
- Printf.eprintf "first_child!\n%!";
- let node' =
- match n.node with
- | Nil | String _ -> failwith "first_child"
- | Node (`Node t) ->
- let fs = first_child n.doc t in
- let txt = prev_text n.doc t in
- if Text.is_empty (text_collection n.doc) txt
- then norm fs
- else Node (`String (txt, fs))
-
- | Node(`String (i,_)) -> String i