(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-02-14 16:45:52 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-13 10:59:20 CET by Kim Nguyen>
*)
open Utils
| PrecedingSibling
| Preceding | Following
-and test = QNameSet.t
+and test = QNameSet.t * Tree.Common.NodeKind.t
and binop = Eq | Neq | Lt | Gt | Lte | Gte | Or | And | Add | Sub | Mult | Div | Mod
and unop = Neg
QNameSet.complement (
QNameSet.from_list [ QName.text;
QName.document;
- QName.cdata_section;
QName.comment])
| Following -> "following"
end
-and print_test fmt ts =
- try
- pp fmt "%s" (List.assoc ts
- [ text,"text()";
- node,"node()";
- star, "*" ] )
- with
- Not_found -> pp fmt "%s"
- (if QNameSet.is_finite ts
- then QName.to_string (QNameSet.choose ts)
- else "<INFINITE>"
- )
+and print_test fmt (ts,kind) =
+ let open Tree.Common.NodeKind in
+ match kind with
+ Text -> pp fmt "%s" "text()"
+ | Element | Attribute ->
+ pp fmt "%s" begin
+ if ts == star then "*"
+ else QName.to_string (QNameSet.choose ts)
+ end
+ | Comment -> pp fmt "%s" "comment()"
+ | ProcessingInstruction ->
+ pp fmt "processing-instruction(%s)"
+ begin
+ if ts == star then ""
+ else "'" ^ (QName.to_string (QNameSet.choose ts)) ^ "'"
+ end
+ | Node -> pp fmt "%s" "node()"
+ | Document -> pp fmt "%s" "<DOCUMENT>"
and print_expr fmt = function
| Number (`Int(i)) -> pp fmt "%i" i
print_expr fmt e0;
if need_par0 then pp fmt ")"
+
+
+let invert_axis = function
+| Self -> Self
+| Attribute -> Parent (* Improve *)
+| Child -> Parent
+| Descendant (b) -> Ancestor (b)
+| FollowingSibling -> PrecedingSibling
+| Parent -> Child
+| Ancestor (b) -> Descendant (b)
+| PrecedingSibling -> FollowingSibling
+| Preceding -> Following
+| Following -> Preceding
+;;
+