X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Fxpath%2Fcompile.ml;h=d33fbb4cc826785c8d9ad91976300eb3e5c78a3a;hp=20f06bec73480a9f74aa9e2e569b57c45d7af524;hb=fe2ba1820282783ae8c10fbbbd2b65d3dc4c67f2;hpb=fed343e8df1900043dc993ac5458c757d3ac2ee0 diff --git a/src/xpath/compile.ml b/src/xpath/compile.ml index 20f06be..d33fbb4 100644 --- a/src/xpath/compile.ml +++ b/src/xpath/compile.ml @@ -42,8 +42,8 @@ let root_set = QNameSet.singleton QName.document let compile_axis_test axis (test,kind) phi trans states = let q = State.next () in let phi = match kind with - Tree.NodeKind.Node -> phi - | _ -> phi %% F.is kind + Tree.NodeKind.Node -> phi + | _ -> phi %% F.is kind in let phi', trans', states' = match axis with @@ -156,9 +156,9 @@ and compile_step_list l trans states = aphi %% ephi, etrans, estates) (phi1, trans1, states1) elist (** - Compile the top-level XPath query in reverse (doing downward + Compile the top-level XPath query in reverse (going downward to the last top-level state): - /a0::t0[p0]/.../an-1::tn-1[pn-1]/an::tn[pn] becomes: + /a0::t0[p0]/../an-1::tn-1[pn-1]/an::tn[pn] becomes: self::node()[ pn and self::tn[pn]/inv(an)::(tn-1)[pn-1]/.../inv(a1)::t0[p0]/inv(a0)::document()] @@ -179,34 +179,34 @@ let compile_top_level_step_list l trans states = (* Only select attribute nodes if the previous axis is attribute *) let phi0 = - if axis != Attribute then + if axis != Attribute && kind == Tree.NodeKind.Node then phi0 %% (F.not_ F.is_attribute) else phi0 in match ll with [] -> - let phi1, trans1, states1 = - List.fold_left (fun (aphi, atrans, astates) e -> + let phi1, trans1, states1 = + List.fold_left (fun (aphi, atrans, astates) e -> let ephi, etrans, estates = compile_expr e atrans astates in aphi %% ephi, etrans, estates) (phi0, trans0, states0) elist - in - let _, trans2, states2 = - compile_axis_test Self (test,kind) phi1 trans1 states1 - in - let marking_state = - StateSet.choose (StateSet.diff states2 states1) - in - marking_state, trans2, states2 + in + let _, trans2, states2 = + compile_axis_test Self (test,kind) phi1 trans1 states1 + in + let marking_state = + StateSet.choose (StateSet.diff states2 states1) + in + marking_state, trans2, states2 | _ -> - let phi1, trans1, states1 = - compile_axis_test Self (test,kind) phi0 trans0 states0 - in - let phi2, trans2, states2 = - List.fold_left (fun (aphi, atrans, astates) e -> + let phi1, trans1, states1 = + compile_axis_test Self (test,kind) phi0 trans0 states0 + in + let phi2, trans2, states2 = + List.fold_left (fun (aphi, atrans, astates) e -> let ephi, etrans, estates = compile_expr e atrans astates in aphi %% ephi, etrans, estates) (phi1, trans1, states1) elist - in - loop ll trans2 states2 phi2 + in + loop ll trans2 states2 phi2 in let starting = State.next () in let phi0, trans0, states0 =