Fix stupid bug with Tag indices
[SXSI/xpathcomp.git] / tree.ml
diff --git a/tree.ml b/tree.ml
index 8ebcdcc..1b4ce2e 100644 (file)
--- a/tree.ml
+++ b/tree.ml
@@ -12,6 +12,7 @@ sig
   type t
   val parse_xml_uri : string -> t
   val parse_xml_string : string -> t
+  val tag_pool : t -> Tag.pool
   val string : t -> string
   val descr : t -> descr
   val left : t -> t
@@ -95,8 +96,8 @@ struct
 
     external is_leaf : t  -> [`Tree] node -> bool = "caml_xml_tree_is_leaf"
     
-    external tag : t -> [`Tree ] node -> Tag.t = "caml_xml_tree_tag"
-    external tag_id : t -> [`Tree ] node -> unit = "caml_xml_tree_tag_id"
+(*    external tag : t -> [`Tree ] node -> T = "caml_xml_tree_tag"*)
+    external tag_id : t -> [`Tree ] node -> Tag.t = "caml_xml_tree_tag_id"
 
     let is_last t n = equal nil (next_sibling t n)
     
@@ -118,7 +119,7 @@ struct
          begin
            Printf.eprintf "Node %i has tag '%s' DocOrder=%i, DocID of PrevText,MyText,NextText : (%i = %s,%i = %s,%i = %s)\n%!" 
              (int_of_node id)
-             (Tag.to_string (tag t id))
+             (Tag.to_string (tag_id t id))
              (node_xml_id t id)
              (int_of_node (prev_text t id))
              (Text.get_text t (prev_text t id))
@@ -180,6 +181,10 @@ struct
     let parse_xml_uri str = node_of_t (parse_xml_uri str)
     let parse_xml_string str = node_of_t (parse_xml_string str)
 
+
+    external pool : doc -> Tag.pool = "%identity"
+    let tag_pool t = pool t.doc
+
     let compare a b = match a.node,b.node  with
       | Node(NC i),Node(NC j) -> compare i j
       | _, Node(NC( _ )) -> 1
@@ -265,14 +270,14 @@ struct
            
     let tag = 
       function { node=Node(SC _) } -> Tag.pcdata
-       | { doc=d; node=Node(NC n)} -> tag d n
-       | _ -> failwith "Tag"
+       | { doc=d; node=Node(NC n)} -> tag_id d n
+       | _ -> failwith "tag"
     
-    let tag_id = 
+(*    let tag_id = 
       function  { node=Node(SC _) } -> ()
        | { doc=d; node=Node(NC n)} -> tag_id d n
        | _ -> ()
-
+*)
     let string_below t id =
       let pid = parent_doc t.doc id in
        match t.node with