2 * ----------------------------------------------------------------------
10 { warner : collect_warnings;
11 errors_with_line_numbers : bool;
12 processing_instructions_inline : bool;
14 debugging_mode : bool;
19 Entity of ((dtd -> Pxp_entity.entity) * Markup_reader.resolver)
20 | Channel of in_channel
23 | ExtID of (ext_id * Markup_reader.resolver)
26 { map : (node_type, 'ext node) Hashtbl.t;
27 default_element : 'ext node;
33 val mutable node = (None : ('a extension node as 'a) option)
46 let default_extension = new default_ext;;
49 { warner = new collect_warnings;
50 errors_with_line_numbers = true;
51 processing_instructions_inline = false;
53 debugging_mode = false;
58 let d = Hashtbl.create 2 in
59 Hashtbl.add d T_data (new data_impl default_extension "");
61 default_element = new element_impl default_extension
67 { Pxp_yacc.default_config with
68 Pxp_yacc.warner = (cfg.warner :> Pxp_types.collect_warnings);
69 Pxp_yacc.errors_with_line_numbers = cfg.errors_with_line_numbers;
70 Pxp_yacc.enable_pinstr_nodes = cfg.processing_instructions_inline;
71 Pxp_yacc.enable_super_root_node = cfg.virtual_root;
72 Pxp_yacc.encoding = `Enc_iso88591;
73 Pxp_yacc.recognize_standalone_declaration = false;
74 Pxp_yacc.debugging_mode = cfg.debugging_mode;
79 class pxp_resolver r =
81 val markup_resolver = r
83 method init_rep_encoding enc =
84 assert (enc = `Enc_iso88591 )
86 method init_warner w =
89 method rep_encoding = `Enc_iso88591
92 markup_resolver # open_in xid
95 markup_resolver # close_in
98 markup_resolver # close_in
100 method change_encoding enc =
101 markup_resolver # change_encoding enc
104 ( {< markup_resolver = markup_resolver # clone >}
105 : #Pxp_reader.resolver :> Pxp_reader.resolver )
112 Entity (mkent, res) -> Pxp_yacc.Entity(mkent, new pxp_resolver res)
113 | ExtID (id, res) -> Pxp_yacc.ExtID(id, new pxp_resolver res)
114 | Channel ch -> Pxp_yacc.from_channel
115 ~system_encoding:`Enc_iso88591 ch
116 | File f -> Pxp_yacc.from_file
117 ~system_encoding:`Enc_iso88591 f
118 | Latin1 s -> Pxp_yacc.from_string ~fixenc:`Enc_iso88591 s
124 try Hashtbl.find dom.map T_data
125 with Not_found -> assert false
127 let eex = dom.default_element in
128 let m = Hashtbl.create 100 in
132 T_element name when name <> "-vr" && name <> "-pi" ->
133 let pxp_ex = ex # pxp_node in
134 Hashtbl.add m name pxp_ex
140 Some ((Hashtbl.find dom.map (T_element "-vr")) # pxp_node)
146 Some ((Hashtbl.find dom.map (T_element "-pi")) # pxp_node)
150 Pxp_document.make_spec_from_mapping
151 ?super_root_exemplar:srex
152 ?default_pinstr_exemplar:piex
153 ~data_exemplar:(dex # pxp_node)
154 ~default_element_exemplar:(eex # pxp_node)
160 let markup_document w index doc =
161 let mdoc = new document w in
162 mdoc # init_xml_version (doc # xml_version);
163 mdoc # init_xml_standalone (doc # xml_standalone);
164 let r = doc # root # extension in
166 mdoc # init_root (r # markup_node);
169 let l = doc # pinstr piname in
171 (fun pi -> mdoc # add_pinstr pi)
173 (doc # pinstr_names);
179 let parse_dtd_entity cfg src =
180 Pxp_yacc.parse_dtd_entity
186 let parse_document_entity cfg src dom =
187 let index = (new Pxp_yacc.hash_index :> 'ext Pxp_yacc.index) in
191 (Pxp_yacc.parse_document_entity
199 let parse_content_entity cfg src dtd dom =
200 let index = (new Pxp_yacc.hash_index :> 'ext Pxp_yacc.index) in
202 (Pxp_yacc.parse_content_entity
207 (pxp_dom dom)) # extension in
213 let parse_wf_entity cfg src dom =
214 let index = (new Pxp_yacc.hash_index :> 'ext Pxp_yacc.index) in
215 (* Restriction: index is not filled! *)
219 (Pxp_yacc.parse_wfdocument_entity
226 (* ======================================================================
230 * Revision 1.1 2000/11/17 09:57:30 lpadovan
233 * Revision 1.4 2000/08/18 20:19:16 gerd
234 * Updates in the emulation because of PXP changes.
236 * Revision 1.3 2000/07/14 21:35:35 gerd
237 * Updated because of the simplification of Pxp_types.collect_warnings.
239 * Revision 1.2 2000/07/08 17:40:50 gerd
240 * Updated the simulation.
242 * Revision 1.1 2000/05/29 23:43:51 gerd
243 * Initial compatibility revision.