]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/pxp_types.mli
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / pxp_types.mli
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
8 type ext_id =
9     System of string
10   | Public of (string * string)
11   | Anonymous
12
13   (* external identifiers are either "system identifiers" (filenames or URLs),
14    * or "public identifiers" Public(id,sysid) where "id" is the representation
15    * of the public ID, and "sysid" a fallback system ID, or the empty string.
16    *
17    * New in PXP: Sometimes the external ID is not known. This case can be
18    * referred to as Anonymous ID.
19    *
20    * Encoding: The identifiers are _always_ encoded as UTF8 strings,
21    * regardless of whether another encoding is configured for the parser.
22    * TODO: umsetzen
23    *)
24
25
26 type dtd_id =
27     External of ext_id       (* DTD is completely external *)
28   | Derived of ext_id        (* DTD is derived from an external DTD *)
29   | Internal                 (* DTD is completely internal *)
30 ;;
31
32 type content_model_type =
33     Unspecified              (* A specification of the model has not yet been
34                               * found
35                               *)
36   | Empty                    (* Nothing is allowed as content *)
37   | Any                      (* Everything is allowed as content *)
38   | Mixed of mixed_spec list (* The contents consist of elements and PCDATA 
39                               * in arbitrary order. What is allowed in
40                               * particular is given as mixed_spec.
41                               *)
42   | Regexp of regexp_spec    (* The contents are elements following this regular
43                               * expression
44                               *)
45
46 and mixed_spec =
47     MPCDATA                  (* PCDATA children are allowed *)
48   | MChild of string         (* This kind of Element is allowed *)
49
50 and regexp_spec =
51     Optional of regexp_spec  (* subexpression? *)
52   | Repeated of regexp_spec  (* subexpression* *)
53   | Repeated1 of regexp_spec (* subexpression+ *)
54   | Alt of regexp_spec list  (* subexpr1 | subexpr2 | ... | subexprN *)
55   | Seq of regexp_spec list  (* subexpr1 , subexpr2 , ... , subexprN *)
56   | Child of string          (* This kind of Element is allowed here *)
57 ;;
58
59
60 type att_type =
61     A_cdata                    (* CDATA *)
62   | A_id                       (* ID *)
63   | A_idref                    (* IDREF *)
64   | A_idrefs                   (* IDREFS *)
65   | A_entity                   (* ENTITY *)
66   | A_entities                 (* ENTiTIES *)
67   | A_nmtoken                  (* NMTOKEN *)
68   | A_nmtokens                 (* NMTOKENS *)
69   | A_notation of string list  (* NOTATION (name1 | name2 | ... | nameN) *)
70   | A_enum of string list      (* (name1 | name2 | ... | nameN) *)
71 ;;
72
73
74 type att_default =
75     D_required           (* #REQUIRED *)
76   | D_implied            (* #IMPLIED *)
77   | D_default of string  (* <value> -- The value is already expanded *)
78   | D_fixed of string    (* FIXED <value> -- The value is already expanded *)
79 ;;
80
81
82 type att_value =
83     Value of string           (* a single value *)
84   | Valuelist of string list  (* a list of values *)
85   | Implied_value             (* a value left out *)
86 ;;
87
88
89 class type collect_warnings =
90   object 
91     method warn : string -> unit
92   end
93 ;;
94
95
96 class drop_warnings : collect_warnings;;
97
98
99 type encoding = Netconversion.encoding;;
100   (* We accept all encodings for character sets which are defined in
101    * Netconversion (package netstring).
102    *)
103
104 type rep_encoding =
105   (* The subset of 'encoding' that may be used for internal representation
106    * of strings.
107    * Note: The following encodings are ASCII-compatible! This is an important
108    * property used throghout the whole PXP code.
109    *)
110   [ `Enc_utf8       (* UTF-8 *)
111   | `Enc_iso88591   (* ISO-8859-1 *)
112   ]
113 ;;
114
115
116 exception Validation_error of string
117   (* Violation of a validity constraint *)
118
119 exception WF_error of string
120   (* Violation of a well-formedness constraint *)
121
122 exception Error of string
123   (* Other error *)
124
125 exception Character_not_supported
126
127 exception At of (string * exn)
128   (* The string is a description where the exn happened. The exn value can
129    * again be At(_,_) (for example, when an entity within an entity causes
130    * the error).
131    *)
132
133 exception Undeclared
134   (* Indicates that declaration is available and because of this every kind
135    * of usage is allowed.
136    *)
137
138 val string_of_exn : exn -> string
139   (* Converts a Markup exception into a readable string *)
140
141
142 type output_stream =
143     Out_buffer of Buffer.t
144   | Out_channel of out_channel
145   | Out_function of (string -> int -> int -> unit)
146
147 val write : output_stream -> string -> int -> int -> unit
148   (* write os s pos len: Writes the string to the buffer/channel/stream *)
149
150 (* ======================================================================
151  * History:
152  * 
153  * $Log$
154  * Revision 1.1  2000/11/17 09:57:29  lpadovan
155  * Initial revision
156  *
157  * Revision 1.8  2000/08/14 22:24:55  gerd
158  *      Moved the module Pxp_encoding to the netstring package under
159  * the new name Netconversion.
160  *
161  * Revision 1.7  2000/07/27 00:41:15  gerd
162  *      new 8 bit codes
163  *
164  * Revision 1.6  2000/07/16 18:31:09  gerd
165  *      The exception Illegal_character has been dropped.
166  *
167  * Revision 1.5  2000/07/16 16:34:21  gerd
168  *      Updated comments.
169  *
170  * Revision 1.4  2000/07/14 21:25:27  gerd
171  *      Simplified the type 'collect_warnings'.
172  *
173  * Revision 1.3  2000/07/08 16:23:50  gerd
174  *      Added the exception 'Error'.
175  *
176  * Revision 1.2  2000/07/04 22:08:26  gerd
177  *      type ext_id: New variant Anonymous. - The System and Public
178  * variants are now encoded as UTF-8.
179  *      collect_warnings is now a class type only. New class
180  * drop_warnings.
181  *      New functions  encoding_of_string and string_of_encoding.
182  *
183  * Revision 1.1  2000/05/29 23:48:38  gerd
184  *      Changed module names:
185  *              Markup_aux          into Pxp_aux
186  *              Markup_codewriter   into Pxp_codewriter
187  *              Markup_document     into Pxp_document
188  *              Markup_dtd          into Pxp_dtd
189  *              Markup_entity       into Pxp_entity
190  *              Markup_lexer_types  into Pxp_lexer_types
191  *              Markup_reader       into Pxp_reader
192  *              Markup_types        into Pxp_types
193  *              Markup_yacc         into Pxp_yacc
194  * See directory "compatibility" for (almost) compatible wrappers emulating
195  * Markup_document, Markup_dtd, Markup_reader, Markup_types, and Markup_yacc.
196  *
197  * ======================================================================
198  * Old logs from Markup_types.mli:
199  *
200  * Revision 1.7  2000/05/29 21:14:57  gerd
201  *      Changed the type 'encoding' into a polymorphic variant.
202  *
203  * Revision 1.6  2000/05/20 20:31:40  gerd
204  *      Big change: Added support for various encodings of the
205  * internal representation.
206  *
207  * Revision 1.5  2000/05/01 20:43:25  gerd
208  *         New type output_stream; new function 'write'.
209  *
210  * Revision 1.4  1999/09/01 16:25:35  gerd
211  *      Dropped Illegal_token and Content_not_allowed_here. WF_error can
212  * be used instead.
213  *
214  * Revision 1.3  1999/08/15 02:22:40  gerd
215  *         Added exception Undeclared.
216  *
217  * Revision 1.2  1999/08/14 22:15:17  gerd
218  *         New class "collect_warnings".
219  *
220  * Revision 1.1  1999/08/10 00:35:52  gerd
221  *      Initial revision.
222  *
223  * 
224  *)