]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic/xmlPushParser.mli
- implemented CicPushParser which parser CIC objects using Expat
[helm.git] / helm / ocaml / cic / xmlPushParser.mli
1 (* Copyright (C) 2004-2005, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (** {2 XLM push parser generic interface}
27  * Do not depend on CIC *)
28
29   (** callbacks needed to instantiate a parser *)
30 type callbacks = {
31   start_element:
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 *)
38 }
39
40   (** do nothing callbacks (all set to None) *)
41 val default_callbacks: callbacks
42
43   (** source from which parse an XML file *)
44 type xml_source =
45   [ `Channel of in_channel
46   | `File of string
47   | `String of string
48   ]
49
50   (** source position in a XML source.
51    * A position is a pair <line, column> *)
52 type position = int * int
53
54 type xml_parser
55
56   (** Create a push parser which invokes the given callbacks *)
57 val create_parser: callbacks -> xml_parser
58
59   (** Parse XML data from a given source with a given parser *)
60 val parse: xml_parser -> xml_source -> unit
61
62   (** Inform the farser that parsing is completed, needed only when source is
63    * `String, for other sources it is automatically invoked when the end of file
64    * is reached *)
65 val final: xml_parser -> unit
66
67   (** @return current <line, column> pair *)
68 val get_position: xml_parser -> position
69