Don't index empty texts
[SXSI/xpathcomp.git] / tree.ml
diff --git a/tree.ml b/tree.ml
index c3a2255..8ebcdcc 100644 (file)
--- a/tree.ml
+++ b/tree.ml
@@ -453,7 +453,11 @@ module DEBUGTREE
          | Node (SC (_,ns)) -> norm ns
          | Node(NC t) ->
              let ns = next_sibling_ n.doc t in
-             let txt = next_text_ n.doc t in
+             let txt = 
+               if XML.Tree.is_nil ns then
+                 next_text_ n.doc t 
+               else prev_text_ n.doc ns
+             in
                if is_empty_ n.doc txt
                then norm ns
                else Node (SC (txt, ns))
@@ -466,7 +470,6 @@ module DEBUGTREE
        | { doc=d;  node=Node(SC (i,_) )} -> text_xml_id_ d i
        | _ -> failwith "id"
            
-
     (* Wrapper around critical function *)
     let string t = time ("TextCollection.GetText()") (string) t
     let left = first_child
@@ -558,4 +561,3 @@ module DEBUGTREE
 end
 
 module Binary = DEBUGTREE
-