(* A selecting state is needed *)
and trans_last (ax,test,pred) =
(* A selecting state is needed *)
and trans_last (ax,test,pred) =
(* Builds asta for predicate and gives the formula which must be satsified *)
and trans_pr_path posi = function
| Relative [] -> if posi then Formula.true_ else Formula.false_
(* Builds asta for predicate and gives the formula which must be satsified *)
and trans_pr_path posi = function
| Relative [] -> if posi then Formula.true_ else Formula.false_
- | Relative steps -> List.fold_left
- (fun acc x -> if posi then (`Left *+ x) +| acc else (`Left *- x) +| acc)
- Formula.false_ (trans_pr_step_l steps)
+ | Relative steps ->
+ let dir = match ax_ (List.hd steps) with
+ | Self -> `Self
+ | FollowingSibling -> `Right
+ | _ -> `Left in
+ List.fold_left
+ (fun acc x -> if posi then (dir *+ x) +| acc else (dir *- x) +| acc)
+ Formula.false_ (trans_pr_step_l steps)
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Absolute steps as x -> print pr_er x; raise Not_core_XPath
| AbsoluteDoS steps as x -> print pr_er x; raise Not_core_XPath
| Absolute steps as x -> print pr_er x; raise Not_core_XPath
(* Builds asta for a predicate query and give the formula *)
and trans_pr_step_l = function
| [step] -> trans_pr_step [] step (Self) (* Self doesn't matter since [] *)
| step :: tl -> let list_top = trans_pr_step_l tl in
(* Builds asta for a predicate query and give the formula *)
and trans_pr_step_l = function
| [step] -> trans_pr_step [] step (Self) (* Self doesn't matter since [] *)
| step :: tl -> let list_top = trans_pr_step_l tl in
(* Add a step on the top of a list of states in a predicate *)
and trans_pr_step list (ax,test,pred) ax_next =
let form_next =
(* Add a step on the top of a list of states in a predicate *)
and trans_pr_step list (ax,test,pred) ax_next =
let form_next =
| Child -> `Right *+ q +| `Right *+ q'
| Descendant -> (`Left *+ q +| `Right *+ q) +| (`Left *+ q' +| `Right *+ q')
| Self -> `Self *+ q'
| Child -> `Right *+ q +| `Right *+ q'
| Descendant -> (`Left *+ q +| `Right *+ q) +| (`Left *+ q' +| `Right *+ q')
| Self -> `Self *+ q'