class dtd :?swarner:Pxp_core_types.I.symbolic_warnings -> Pxp_core_types.I.collect_warnings -> Pxp_core_types.I.rep_encoding ->
object
..end
Pxp_dtd.create_dtd
.
Despite its name, this object does not only define the DTD as such (i.e. what would be found in a ".dtd" file), but all formal requirements of documents that are needed by PXP. This also includes:
For some introductory words about well-formedness mode, see
Parsing in well-formedness mode.
method root : string option
method set_root : string -> unit
method id : Pxp_core_types.I.dtd_id option
None
: There is no DOCTYPE declaration, or only
<!DOCTYPE name>
Some Internal
: There is a DOCTYPE declaration with material
in brackets like <!DOCTYPE name [ declarations ... ]>
Some(External xid)
: There is a DOCTYPE declaration with
a SYSTEM or PUBLIC identifier (described by xid
), but without
brackets, i.e. <!DOCTYPE name SYSTEM '...'>
or
<!DOCTYPE name PUBLIC '...' '...'>
.Some(Derived xid)
: There is a DOCTYPE declaration with
a SYSTEM or PUBLIC identifier (described by xid
), and with
bracketsmethod set_id : Pxp_core_types.I.dtd_id -> unit
method encoding : Pxp_core_types.I.rep_encoding
method lexer_factory : Pxp_lexer_types.lexer_factory
method allow_arbitrary : unit
arbitrary_allowed
flag. This flag disables
a specific validation constraint, namely that all elements
need to be declared in the DTD. This feature is used
to implement the well-formedness mode: In this mode, the element,
attribute, and notation declarations found in the textual DTD are ignored, and not
added to this DTD object. As the arbitrary_allowed
flag is also
set, the net effect is that all validation checks regarding
the values of elements and attributes are omitted. The flag is
automatically set if the parser is called using one of the
"wf" functions, e.g. Pxp_tree_parser.parse_wfdocument_entity
.
Technically, the arbitrary_allowed
flag changes the behaviour of
the element
and notation
methods defined below so that they
raise Undeclared
instead of Validation_error
when an unknown
element or notation name is encountered.
method disallow_arbitrary : unit
arbitrary_allowed
flag againmethod arbitrary_allowed : bool
method standalone_declaration : bool
method set_standalone_declaration : bool -> unit
method namespace_manager : namespace_manager
Not_found
is raised.method set_namespace_manager : namespace_manager -> unit
namespace_manager
.method add_element : dtd_element -> unit
Not_found
if there is already an element declaration with the same name.method add_gen_entity : Pxp_entity.entity -> bool -> unit
add_gen_entity e extdecl
:
add the entity e
as general entity to this DTD (general entities
are those represented by &name;
). If there is already a declaration
with the same name, the second definition is ignored; as exception from
this rule, entities with names "lt", "gt", "amp", "quot", and "apos"
may only be redeclared with a definition that is equivalent to the
standard definition; otherwise a Validation_error
is raised.
extdecl
: true indicates that the entity declaration occurs in
an external entity. (Used for the standalone check.)
method add_par_entity : Pxp_entity.entity -> unit
method add_notation : dtd_notation -> unit
Validation_error
is raised.method add_pinstr : proc_instruction -> unit
method element : string -> dtd_element
Validation_error
if the element cannot be found. If the
arbitrary_allowed
flag is set, however,
Undeclared
is raised instead.method element_names : string list
method gen_entity : string -> Pxp_entity.entity * bool
let e, extdecl = obj # gen_entity n
:
looks up the general entity e
with the name n
. Raises
WF_error
if the entity cannot be found.
extdecl
: indicates whether the entity declaration occured in an
external entity.
method gen_entity_names : string list
method par_entity : string -> Pxp_entity.entity
WF_error
if the entity cannot be found.method par_entity_names : string list
method notation : string -> dtd_notation
Validation_error
if the notation cannot be found. If the
arbitrary_allowed
flag is sez, however,
Undeclared
is raised instead.method notation_names : string list
method pinstr : string -> proc_instruction list
<?
.method pinstr_names : string list
method validate : unit
Validation_error
is raised,
but other exceptions are possible, too.method only_deterministic_models : unit
Validation_error
.method write : ?root:string ->
Pxp_core_types.I.output_stream -> Pxp_core_types.I.encoding -> bool -> unit
write os enc doctype
:
Writes the DTD as enc
-encoded string to os
. If doctype
, a
DTD like <!DOCTYPE root [ ... ]>
is written. If not doctype
,
only the declarations are written (the material within the
square brackets).
The entity definitions are not written. However, it is ensured that the generated string does not contain any reference to an entity. The reason for the omission of the entites is that there is no generic way of writing references to external entities.
Option root
: Override the name of the root element in the
DOCTYPE clause.
method write_ref : ?root:string ->
Pxp_core_types.I.output_stream -> Pxp_core_types.I.encoding -> unit
write_ref os enc
:
Writes a reference to the DTD as enc
-encoded string to os
.
The reference looks as follows:
<!DOCTYPE root SYSTEM ... > or
<!DOCTYPE root PUBLIC ... >
Of course, the DTD must have an external ID:write_ref
will fail.
If the ID is anonymous or private, the method will fail, too.
Option root
: Override the name of the root element in the
DOCTYPE clause.