1 (* Copyright (C) 2004-2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 (** {2 XLM push parser generic interface}
27 * Do not depend on CIC *)
29 (** callbacks needed to instantiate a parser *)
32 (string -> (string * string) list -> unit) option; (* tag, attr list *)
33 end_element: (string -> unit) option; (* tag *)
34 character_data: (string -> unit) option; (* data *)
35 processing_instruction:
36 (string -> string -> unit) option; (* target, value *)
37 comment: (string -> unit) option; (* value *)
40 (** do nothing callbacks (all set to None) *)
41 val default_callbacks: callbacks
43 (** source from which parse an XML file *)
45 [ `Channel of in_channel
47 | `Gzip_channel of Gzip.in_channel
48 | `Gzip_file of string
52 (** source position in a XML source.
53 * A position is a pair <line, column> *)
54 type position = int * int
58 (** raised when a parse error occurs, argument is an error message.
59 * This exception carries no position information, but it should be get using
60 * get_position below *)
61 exception Parse_error of string
63 (** Create a push parser which invokes the given callbacks *)
64 val create_parser: callbacks -> xml_parser
66 (** Parse XML data from a given source with a given parser
67 * @raise Parse_error *)
68 val parse: xml_parser -> xml_source -> unit
70 (** Inform the parser that parsing is completed, needed only when source is
71 * `String, for other sources it is automatically invoked when the end of file
73 * @raise Parse_error *)
74 val final: xml_parser -> unit
76 (** @return current <line, column> pair *)
77 val get_position: xml_parser -> position