]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/pxp_types.ml
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / pxp_types.ml
1 (* $Id$
2  * ----------------------------------------------------------------------
3  * PXP: The polymorphic XML parser for Objective Caml.
4  * Copyright 1999 by Gerd Stolpmann. See LICENSE for details.
5  *)
6
7 type ext_id =
8     System of string
9   | Public of (string * string)
10   | Anonymous
11
12
13 type dtd_id =
14     External of ext_id
15   | Derived of ext_id
16   | Internal
17 ;;
18
19 type content_model_type =
20     Unspecified
21   | Empty
22   | Any
23   | Mixed of mixed_spec list
24   | Regexp of regexp_spec
25
26 and mixed_spec =
27     MPCDATA
28   | MChild of string
29
30 and regexp_spec =
31     Optional of regexp_spec
32   | Repeated of regexp_spec
33   | Repeated1 of regexp_spec
34   | Alt of regexp_spec list
35   | Seq of regexp_spec list
36   | Child of string
37 ;;
38
39
40 type att_type =
41     A_cdata
42   | A_id
43   | A_idref
44   | A_idrefs
45   | A_entity
46   | A_entities
47   | A_nmtoken
48   | A_nmtokens
49   | A_notation of string list
50   | A_enum of string list
51 ;;
52
53
54 type att_default =
55     D_required
56   | D_implied
57   | D_default of string  (* The default value is already expanded *)
58   | D_fixed of string    (* The default value is already expanded *)
59 ;;
60
61
62 type att_value =
63     Value of string
64   | Valuelist of string list
65   | Implied_value
66 ;;
67
68
69 class type collect_warnings =
70   object 
71     method warn : string -> unit
72   end
73 ;;
74
75
76 class drop_warnings =
77   object 
78     method warn (w:string) = ()
79   end
80 ;;
81
82
83 type encoding = Netconversion.encoding;;
84
85 type rep_encoding =
86   (* The subset of 'encoding' that may be used for internal representation
87    * of strings.
88    *)
89   [  `Enc_utf8       (* UTF-8 *)
90   |  `Enc_iso88591   (* ISO-8859-1 *)
91   ]
92 ;;
93
94
95 exception Validation_error of string
96
97 exception WF_error of string
98
99 exception Error of string
100
101 exception Character_not_supported
102
103 exception At of (string * exn)
104
105 exception Undeclared
106
107
108 let rec string_of_exn x0 =
109   match x0 with
110       At (s, x) ->
111         s ^ string_of_exn x
112     | Validation_error s ->
113         "ERROR (Validity constraint): "  ^ s
114     | WF_error s ->
115         "ERROR (Well-formedness constraint): " ^ s
116     | Error s ->
117         "ERROR: " ^ s
118     | Character_not_supported ->
119         "RESTRICTION: Character not supported"
120     | Netconversion.Malformed_code ->
121         "ERROR: Bad character stream"
122     | Undeclared ->
123         "INFORMATION: Undeclared"
124     | Parsing.Parse_error ->
125         "SYNTAX ERROR"
126     | _ ->
127         "Other exception: " ^ Printexc.to_string x0
128 ;;
129
130
131 type output_stream =
132     Out_buffer of Buffer.t
133   | Out_channel of out_channel
134   | Out_function of (string -> int -> int -> unit)
135 ;;
136
137
138 let write os str pos len =
139   match os with
140       Out_buffer b -> Buffer.add_substring b str pos len
141     | Out_channel ch -> output ch str pos len
142     | Out_function f -> f str pos len
143 ;;
144
145 (* ======================================================================
146  * History:
147  *
148  * $Log$
149  * Revision 1.1  2000/11/17 09:57:29  lpadovan
150  * Initial revision
151  *
152  * Revision 1.7  2000/08/14 22:24:55  gerd
153  *      Moved the module Pxp_encoding to the netstring package under
154  * the new name Netconversion.
155  *
156  * Revision 1.6  2000/07/27 00:41:15  gerd
157  *      new 8 bit codes
158  *
159  * Revision 1.5  2000/07/16 18:31:09  gerd
160  *      The exception Illegal_character has been dropped.
161  *
162  * Revision 1.4  2000/07/14 21:25:27  gerd
163  *      Simplified the type 'collect_warnings'.
164  *
165  * Revision 1.3  2000/07/08 16:23:50  gerd
166  *      Added the exception 'Error'.
167  *
168  * Revision 1.2  2000/07/04 22:14:05  gerd
169  *      Implemented the changes of rev. 1.2 of pxp_types.mli.
170  *
171  * Revision 1.1  2000/05/29 23:48:38  gerd
172  *      Changed module names:
173  *              Markup_aux          into Pxp_aux
174  *              Markup_codewriter   into Pxp_codewriter
175  *              Markup_document     into Pxp_document
176  *              Markup_dtd          into Pxp_dtd
177  *              Markup_entity       into Pxp_entity
178  *              Markup_lexer_types  into Pxp_lexer_types
179  *              Markup_reader       into Pxp_reader
180  *              Markup_types        into Pxp_types
181  *              Markup_yacc         into Pxp_yacc
182  * See directory "compatibility" for (almost) compatible wrappers emulating
183  * Markup_document, Markup_dtd, Markup_reader, Markup_types, and Markup_yacc.
184  *
185  * ======================================================================
186  * Old logs from markup_types.ml:
187  *
188  * Revision 1.7  2000/05/29 21:14:57  gerd
189  *      Changed the type 'encoding' into a polymorphic variant.
190  *
191  * Revision 1.6  2000/05/20 20:31:40  gerd
192  *      Big change: Added support for various encodings of the
193  * internal representation.
194  *
195  * Revision 1.5  2000/05/01 20:43:19  gerd
196  *      New type output_stream; new function 'write'.
197  *
198  * Revision 1.4  1999/09/01 16:25:35  gerd
199  *      Dropped Illegal_token and Content_not_allowed_here. WF_error can
200  * be used instead.
201  *
202  * Revision 1.3  1999/08/15 02:22:33  gerd
203  *      Added exception Undeclared.
204  *
205  * Revision 1.2  1999/08/14 22:14:58  gerd
206  *      New class "collect_warnings".
207  *
208  * Revision 1.1  1999/08/10 00:35:52  gerd
209  *      Initial revision.
210  *
211  *
212  *)