1 (***********************************************************************)
5 (* Kim Nguyen, LRI UMR8623 *)
6 (* Université Paris-Sud & CNRS *)
8 (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (* Recherche Scientifique. All rights reserved. This file is *)
10 (* distributed under the terms of the GNU Lesser General Public *)
11 (* License, with the special exception on linking described in file *)
14 (***********************************************************************)
17 Time-stamp: <Last modified on 2013-03-11 00:12:27 CET by Kim Nguyen>
20 (** Implementation of documents as binary trees *)
25 (** The type of a tree node *)
28 (** The type of trees *)
31 (** Nil node, denoting the first/second child of a leaf or the parent of
35 (** Dummy node that is guaranteed to never occur in any tree *)
37 val load_xml_file : in_channel -> t
38 (** Takes a file descriptor and returns the XML data stored in the
39 corresponding file. Start at the current position in the file
40 descriptor (which is not necessarily the begining of file)
43 val load_xml_string : string -> t
44 (** Loads XML data stored in a string *)
46 val print_xml : out_channel -> t -> node -> unit
47 (** Outputs the tree as an XML document on the given output_channel *)
50 (** Returns the root of the tree *)
52 val first_child : t -> node -> node
53 (** [first_child t n] returns the first child of node [n] in tree [t].
54 Returns [nil] if [n] is a leaf. Returns [nil] if [n == nil].
57 val next_sibling : t -> node -> node
58 (** [next_sibling t n] returns the next_sibling of node [n] in tree [t].
59 Returns [nil] if [n] is the last child of a node.
60 Returns [nil] if [n == nil].
63 val parent : t -> node -> node
64 (** [next_sibling t n] returns the parent of node [n] in tree [t].
65 Returns [nil] if [n] is the root of the tree.
66 Returns [nil] if [n == nil].
69 val tag : t -> node -> Utils.QName.t
70 (** Returns the label of a given node *)
72 val data : t -> node -> string
73 (** Returns the character data associated with a node.
74 The only node having character data are those whose label is
75 QName.text, QName.cdata_section or QName.comment
78 val kind : t -> node -> Common.NodeKind.t
79 (** Returns the kind of the given node *)
81 val preorder : t -> node -> int
82 (** Returns the position of a node in pre-order in the tree. The
83 root has preorder 0. [nil] has pre-order [-1].
86 val print_node : Format.formatter -> node -> unit