Fix descendant-or-self (which wrongly looked for elements in the
authorKim Nguyễn <kn@lri.fr>
Sun, 10 Mar 2013 11:33:36 +0000 (12:33 +0100)
committerKim Nguyễn <kn@lri.fr>
Sun, 10 Mar 2013 11:33:36 +0000 (12:33 +0100)
right sibling of self)

src/xpath/compile.ml

index 1c46b8f..7848b84 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-03-09 19:17:26 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-10 12:28:07 CET by Kim Nguyen>
 *)
 
 open Ast
 *)
 
 open Ast
@@ -70,12 +70,20 @@ let compile_axis_test ?(block_attr=true) axis test phi trans states =
                QNameSet.any => F.next_sibling q ]) :: trans,
          states)
 
                QNameSet.any => F.next_sibling q ]) :: trans,
          states)
 
-    | Descendant self ->
-        ((if self then F.stay q else F.first_child q),
+    | Descendant false ->
+        (F.first_child q,
          (q, [ test => phi %% phi_attr;
                QNameSet.any => F.first_child q ++ F.next_sibling q;
              ]) :: trans,
          states)
          (q, [ test => phi %% phi_attr;
                QNameSet.any => F.first_child q ++ F.next_sibling q;
              ]) :: trans,
          states)
+    | Descendant true ->
+        let q' = State.make () in
+        (F.or_ (F.stay q) (F.first_child q'),
+         (q', [ test => phi %% phi_attr;
+               QNameSet.any => F.first_child q' ++ F.next_sibling q';
+             ])::
+         (q, [ test => phi %% phi_attr]):: trans,
+         states)
 
     | Parent ->
         let q' = State.make () in
 
     | Parent ->
         let q' = State.make () in