X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fxpath%2Fast.ml;h=d70227bed900fd4421bf2892570e489200109685;hb=35c32fbd2543a399cc6939f21317bebf37172646;hp=c3c00d9d1ee551f85f00290dd8658ff9b253084a;hpb=30bc0bb1291426e5e26eb2dee1ffc41e4c246349;p=tatoo.git diff --git a/src/xpath/ast.ml b/src/xpath/ast.ml index c3c00d9..d70227b 100644 --- a/src/xpath/ast.ml +++ b/src/xpath/ast.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Utils @@ -22,8 +22,13 @@ open Utils type path = single_path list and single_path = Absolute of step list | Relative of step list and step = axis * test * expr list -and axis = Self | Attribute | Child | Descendant | DescendantOrSelf | FollowingSibling - | Parent | Ancestor | AncestorOrSelf | PrecedingSibling | Preceding | Following +and axis = Self | Attribute | Child + | Descendant of bool (* true = descendant-or-self, false = descendant *) + | FollowingSibling + | Parent + | Ancestor of bool (* true = ancestor-or-self, false = ancestor *) + | PrecedingSibling + | Preceding | Following and test = QNameSet.t @@ -111,12 +116,12 @@ and print_axis fmt a = pp fmt "%s" begin match a with Self -> "self" | Child -> "child" - | Descendant -> "descendant" - | DescendantOrSelf -> "descendant-or-self" + | Descendant false -> "descendant" + | Descendant true -> "descendant-or-self" | FollowingSibling -> "following-sibling" | Attribute -> "attribute" - | Ancestor -> "ancestor" - | AncestorOrSelf -> "ancestor-or-self" + | Ancestor false -> "ancestor" + | Ancestor true -> "ancestor-or-self" | PrecedingSibling -> "preceding-sibling" | Parent -> "parent" | Preceding -> "preceding" @@ -163,3 +168,17 @@ and print_expr fmt = function print_expr fmt e0; if need_par0 then pp fmt ")" + + +let invert_axis = function +| Self | Attribute as a -> a +| Child -> Parent +| Descendant (b) -> Ancestor (b) +| FollowingSibling -> PrecedingSibling +| Parent -> Child +| Ancestor (b) -> Descendant (b) +| PrecedingSibling -> FollowingSibling +| Preceding -> Following +| Following -> Preceding +;; +