From: Kim Nguyễn Date: Sun, 10 Mar 2013 11:33:36 +0000 (+0100) Subject: Fix descendant-or-self (which wrongly looked for elements in the X-Git-Tag: v0.1~143 X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=commitdiff_plain;h=9d83bf3832f03462a5d1f451d96e8d30347bf363 Fix descendant-or-self (which wrongly looked for elements in the right sibling of self) --- diff --git a/src/xpath/compile.ml b/src/xpath/compile.ml index 1c46b8f..7848b84 100644 --- a/src/xpath/compile.ml +++ b/src/xpath/compile.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) 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) - | 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) + | 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