146
val create_namespace_manager : unit -> namespace_manager
147
(* Preferred way of creating a namespace_manager *)
150
(** The recursive class type [namespace_scope] represents the original
151
* namespace declarations found in the XML text. A single [namespace_scope]
152
* object contains a list of declared namespaces
153
* {[ [ (dp1, uri1); (dp2; uri2); ... ] ]}
154
* corresponding to the "xmlns"-type declarations found in a single
156
* {[ <element xmlns:dp1="uri1" xmlns:dp2="uri2" ... > ]}
157
* For the declaration of a default namespace [xmlns="uri"] the pair
158
* [("",uri)] must be included in the list. The special pair [("","")]
159
* means that the former default namespace is "undeclared".
161
* Furthermore, the [namespace_scope] object may have a parent
162
* [namespace_scope], representing the namespace declarations in the
163
* surrounding XML text.
165
* The [namespace_scope] objects are connected with the [namespace_manager]
166
* to allow translations from the namespace prefixes found in the XML
167
* text (also called "display prefixes" from now on) to the normalized
168
* prefixes stored in the [namespace_manager], and vice versa.
170
* The [namespace_scope] objects are intentionally immutable in order to
171
* allow memory sharing.
173
class type namespace_scope =
175
method namespace_manager : namespace_manager
176
(** Returns the [namespace_manager] to which this scope object is
179
method parent_scope : namespace_scope option
180
(** Returns the parent object, if any *)
181
method declaration : (string * string) list
182
(** Returns the list of namespace declarations of this scope (i.e.
183
* the declarations in parent objects are not considered). The
184
* list contains pairs [ (display_prefix, uri) ].
186
method effective_declaration : (string * string) list
187
(** Returns the list of namespace declarations of this scope and
188
* all parent scopes. The list contains pairs [ (display_prefix, uri) ].
189
* Prefixes hidden by earlier declarations are suppressed in the list
191
method display_prefix_of_uri : string -> string
192
(** Translates the URI to the corresponding display prefix as declared
193
* in this object or any parent object. Raises [Namespace_not_in_scope]
194
* when the declaration cannot be found.
196
method display_prefix_of_normprefix : string -> string
197
(** Translates the normalized prefix to the corresponding display
198
* prefix as declared in this object or any parent object. Raises
199
* [Namespace_not_in_scope] when the declaration cannot be found, and
200
* [Namespace_prefix_not_managed] when the
201
* normalized prefix is unknown to the namespace manager.
203
method uri_of_display_prefix : string -> string
204
(** Translates the display prefix to the corresponding URI as
205
* declared in this object or any parent object. Raises
206
* [Not_found] when the declaration cannot be found.
208
method normprefix_of_display_prefix : string -> string
209
(** Translates the display prefix to the corresponding normalized
210
* prefix as declared in this object or any parent object. Raises
211
* [Not_found] when the declaration cannot be found, and
212
* [Namespace_not_managed] when the
213
* namespace manager does not know the namespace.
219
class namespace_scope_impl :
221
namespace_scope option ->
222
(string * string) list ->
224
(** An implementation of [namespace_scope]. New scopes are created by
225
* {[ new namespace_scope_impl mng parent_opt decl ]}
226
* where [mng] is the namespace managaer, [parent_opt] is the optional
227
* parent scope, and [decl] is the declaration list.
231
val create_namespace_scope :
232
?parent:namespace_scope ->
233
?decl:(string * string) list ->
236
(* Preferred way of creating a namespace_scope *)
131
242
* creates a new, empty DTD object without any declaration, without a root
132
243
* element, without an ID.
134
Pxp_types.collect_warnings ->
135
Pxp_types.rep_encoding ->
245
?swarner:Pxp_core_types.symbolic_warnings ->
246
Pxp_core_types.collect_warnings ->
247
Pxp_core_types.rep_encoding ->
137
249
method root : string option
138
(* get the name of the root element if present *)
250
(* get the name of the root element if present. This is the name
251
* following "<!DOCTYPE". If there is no DOCTYPE declaration,
252
* this method will return None.
140
255
method set_root : string -> unit
141
256
(* set the name of the root element. This method can be invoked
145
method id : Pxp_types.dtd_id option
146
(* get the identifier for this DTD *)
148
method set_id : Pxp_types.dtd_id -> unit
257
* only once (usually by the parser)
260
method id : Pxp_core_types.dtd_id option
261
(* get the identifier for this DTD. Possible return values:
262
* None: There is no DOCTYPE declaration, or only
264
* Some Internal: There is a DOCTYPE declaration with material
265
* in brackets like "<!DOCTYPE name [ declarations ... ]>"
266
* Some(External xid): There is a DOCTYPE declaration with
267
* a SYSTEM or PUBLIC identifier (described by xid), but without
268
* brackets, i.e. "<!DOCTYPE name SYSTEM '...'>" or
269
* "<!DOCTYPE name PUBLIC '...' '...'>".
270
* Some(Derived xid): There is a DOCTYPE declaration with
271
* a SYSTEM or PUBLIC identifier (described by xid), _and_ with
275
method set_id : Pxp_core_types.dtd_id -> unit
149
276
(* set the identifier. This method can be invoked only once *)
151
method encoding : Pxp_types.rep_encoding
278
method encoding : Pxp_core_types.rep_encoding
152
279
(* returns the encoding used for character representation *)
281
method lexer_factory : Pxp_lexer_types.lexer_factory
282
(** Returns a lexer factory for the character encoding *)
155
285
method allow_arbitrary : unit
156
286
(* After this method has been invoked, the object changes its behaviour:
568
739
* ~doc_entity: If true, the entity is a document entity. XML requires
569
740
* some additional restrictions for document entities. The default for
570
741
* the argument is false.
742
* ~system_base: The base URL if SYSTEM identifiers are passed
573
746
val from_external_source :
574
747
?doc_entity:bool ->
575
name:string -> dtd -> source ->
576
751
Pxp_entity.entity
577
752
(* Creates an external entity that reads from the passed source *)
754
val entity_id : Pxp_entity.entity -> Pxp_lexer_types.entity_id
755
(* Returns the abstract entity ID *)
757
val create_entity_id : unit -> Pxp_lexer_types.entity_id
758
(* Create a new abstract entity ID. This ID can be used whereever
759
* an entity_id is expected but no entity is available.
584
(* ======================================================================
587
* $Log: pxp_dtd.mli,v $
588
* Revision 1.16 2002/03/10 23:39:28 gerd
589
* Extended the Entity module
591
* Revision 1.15 2001/12/03 23:45:55 gerd
592
* new method [write_ref]
594
* Revision 1.14 2001/07/02 23:21:40 gerd
595
* Added the Entity module.
597
* Revision 1.13 2001/06/08 01:15:47 gerd
598
* Moved namespace_manager from Pxp_document to Pxp_dtd. This
599
* makes it possible that the DTD can recognize the processing instructions
600
* <?pxp:dtd namespace prefix="..." uri="..."?>, and add the namespace
601
* declaration to the manager.
603
* Revision 1.12 2001/06/07 22:49:11 gerd
604
* Removed: method write_compact_as_latin1
606
* Revision 1.11 2000/10/01 19:46:57 gerd
607
* Changed type of the att_lookup component.
609
* Revision 1.10 2000/09/22 22:54:30 gerd
610
* Optimized the attribute checker (internal_init of element
611
* nodes). The validation_record has now more fields to support
614
* Revision 1.9 2000/09/09 16:41:32 gerd
615
* New type validation_record.
617
* Revision 1.8 2000/08/18 21:18:45 gerd
618
* Updated wrong comments for methods par_entity and gen_entity.
619
* These can raise WF_error and not Validation_error, and this is the
622
* Revision 1.7 2000/07/25 00:30:01 gerd
623
* Added support for pxp:dtd PI options.
625
* Revision 1.6 2000/07/23 02:16:33 gerd
628
* Revision 1.5 2000/07/16 16:34:41 gerd
629
* New method 'write', the successor of 'write_compact_as_latin1'.
631
* Revision 1.4 2000/07/14 13:56:49 gerd
632
* Added methods id_attribute_name and idref_attribute_names.
634
* Revision 1.3 2000/07/09 00:13:37 gerd
635
* Added methods gen_entity_names, par_entity_names.
637
* Revision 1.2 2000/06/14 22:19:06 gerd
638
* Added checks such that it is impossible to mix encodings.
640
* Revision 1.1 2000/05/29 23:48:38 gerd
641
* Changed module names:
642
* Markup_aux into Pxp_aux
643
* Markup_codewriter into Pxp_codewriter
644
* Markup_document into Pxp_document
645
* Markup_dtd into Pxp_dtd
646
* Markup_entity into Pxp_entity
647
* Markup_lexer_types into Pxp_lexer_types
648
* Markup_reader into Pxp_reader
649
* Markup_types into Pxp_types
650
* Markup_yacc into Pxp_yacc
651
* See directory "compatibility" for (almost) compatible wrappers emulating
652
* Markup_document, Markup_dtd, Markup_reader, Markup_types, and Markup_yacc.
654
* ======================================================================
655
* Old logs from markup_dtd.ml:
657
* Revision 1.11 2000/05/29 21:14:57 gerd
658
* Changed the type 'encoding' into a polymorphic variant.
660
* Revision 1.10 2000/05/27 19:20:38 gerd
661
* Changed the interfaces for the standalone check: New
662
* methods: standalone_declaration, set_standalone_declaration,
663
* externally_declared, attribute_violates_standalone_declaration.
664
* The method set_content_model has been renamed to
665
* set_cm_and_extdecl; it now initializes also whether the element
666
* has been declared in an external entity.
667
* Methods add_gen_entity and gen_entity pass an additional
668
* boolean argument containing whether the declaration of the
669
* general entity happened in an external entity.
670
* Method add_attribute expects this argument, too, which
671
* states whether the declaration of the attribute happened in an
674
* Revision 1.9 2000/05/20 20:31:40 gerd
675
* Big change: Added support for various encodings of the
676
* internal representation.
678
* Revision 1.8 2000/05/06 23:10:26 gerd
679
* allow_arbitrary for elements, too.
681
* Revision 1.7 2000/05/01 20:42:52 gerd
682
* New method write_compact_as_latin1.
684
* Revision 1.6 2000/03/11 22:58:15 gerd
685
* Updated to support Markup_codewriter.
687
* Revision 1.5 2000/02/22 02:32:02 gerd
690
* Revision 1.4 1999/11/09 22:15:41 gerd
691
* Added method "arbitrary_allowed".
693
* Revision 1.3 1999/09/01 16:21:56 gerd
694
* "dtd" classes have now an argument that passes a "warner".
696
* Revision 1.2 1999/08/15 02:20:23 gerd
697
* New feature: a DTD can allow arbitrary elements.
699
* Revision 1.1 1999/08/10 00:35:51 gerd