X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Ftree.ml;h=9e6c71ca61a4a0dd8a3ba8d6c088810e2d5916cb;hp=e06a11e5ff8d6c1a855e82d7f3eb262988515cec;hb=1947a98f419c2bf50378fed783406818b010c60e;hpb=5b5dcd45cf86701ccfe917c1d6ad73b83bb523c3 diff --git a/src/tree.ml b/src/tree.ml index e06a11e..9e6c71c 100644 --- a/src/tree.ml +++ b/src/tree.ml @@ -13,16 +13,13 @@ (* *) (***********************************************************************) -(* - Time-stamp: -*) - (** The different kind of XML nodes and utility functions *) module NodeKind = struct type t = - Document | Element | Text | Comment | Attribute | ProcessingInstruction | Node + Document | Element | Text | Comment | Attribute + | ProcessingInstruction | Node let to_string = function @@ -108,9 +105,23 @@ sig (** Returns the kind of the given node *) val preorder : t -> node -> int - (** Returns the position of a node in pre-order in the tree. The - root has preorder 0. [nil] has pre-order [-1]. + (** [preorder t n] returns the pre-order position of [n] in [t]. + [preodrder t (root t) == 0] and [preorder t nil < 0]. *) + val by_preorder : t -> int -> node + (** [by_preorder t i] returns the node with preorder [i] + *) val print_node : Format.formatter -> node -> unit + + val is_first_child : t -> node -> bool + val is_next_sibling : t -> node -> bool + val prev_sibling : t -> node -> node + (** [prev_sibling t n] returns the previous_sibling of node [n] in tree [t]. + Returns [nil] if [n] is the first child of a node. + *) + val parent_of_first : t -> node -> node + (** [parent_of_first t n] returns the parent of node [n] in tree [t] . + Returns [nil] if [n] isn't the first child of a node. + *) end