module Pxp_event:Dealing with events (for pull parsing)sig..end
val to_list : (unit -> Pxp_types.event option) -> Pxp_types.event listval of_list : Pxp_types.event list -> unit -> Pxp_types.event optionof_list l: Create a pull function fetching the events from lval concat : (unit -> Pxp_types.event option) list -> unit -> Pxp_types.event optionlet p = concat l: The pull functions contained in the list l are
concatenated, and a new pull function p is created that pulls from
the functions of the list in turn (when one function indicates
the end of the events, it is continued with the next function in the
list).val iter : (Pxp_types.event -> unit) -> (unit -> Pxp_types.event option) -> unititer f p: The pull function p is repeatedly called to get a
stream of events e. For each event the function f is called.val extract : Pxp_types.event ->
(unit -> Pxp_types.event option) -> unit -> Pxp_types.event optionlet next' = extract e next:
Extracts a subexpression from the pull function next prepended by e.
A subexpression consists of eitherExample:
let l = [ E_pinstr; E_start_tag; E_data; E_start_tag; E_end_tag;
E_comment; E_end_tag; E_data ];;
let g = of_list l;;
g();;
let Some e = g();; (* e = E_start_tag *)
let g' = extract e g;;
g'();; (* returns Some E_start_tag *)
...
g'();; (* returns Some E_end_tag *)
g'();; (* returns None, end of subexpression *)
g();; (* returns Some E_data *)
g();; (* returns None *)
typepull_fn =unit -> Pxp_types.event option
Pxp_ev_parser.create_pull_parsertypefilter =pull_fn -> pull_fn
val norm_cdata_filter : filterE_char_data eventsE_char_data eventsval drop_ignorable_whitespace_filter : filterWF_Error will be raised.
This filter works only if the DTD found in the event stream
actually contains element declarations. This is usually enabled
by including the `Extend_dtd_fully or `Val_mode_dtd options to
the entry passed to the create_pull_parser call. Furthermore,
there must be an E_start_doc event.
This filter does not perform any other validation checks.
val pfilter : (Pxp_types.event -> bool) -> filterExample: Remove comments:
pfilter (function E_comment _ -> false | _ -> true) g val unwrap_document : pull_fn -> (unit -> string * Pxp_dtd.dtd) * pull_fn
let (get_doc_details, next') = unwrap_document next
let (version, dtd) = get_doc_details()
The returned filter removes any E_start_doc, E_end_doc,
E_start_super, E_end_super, and E_end_of_stream events.
If an E_error event is encountered, the contained exception
is raised. All other events of the stream remain.
The function get_doc_details can be called to get details
about the document definition. If an E_start_doc event is
found in the stream, the XML version string and the DTD
object are returned. The function fails if E_start_doc is
not the first event of the stream.
E_start_tag can be analyzed with the following.val namespace_split : string -> string * stringlet (p,l) = namespace_split name: Splits name into the prefix
p and the local name l. If there is no colon in name, the
function returns p="", and l=name.val extract_prefix : string -> string"" if there is no prefix.
Same as fst(namespace_split name).typedtd_style =[ `Ignore | `Include | `Reference ]
val write_events : ?default:string ->
?dtd_style:dtd_style ->
?minimization:[ `AllEmpty | `None ] ->
Pxp_types.output_stream ->
Pxp_types.encoding ->
Pxp_types.rep_encoding -> (unit -> Pxp_types.event option) -> unitoutput_stream. The events must be encoded
as indicated by the rep_encoding argument, but the output is written
as specified by the encoding argument.
The normalized namespace prefixes are declared as needed. Additionally,
one can set the default namespace by passing default, which must be
the normalized prefix of the default namespace.
For E_doc_start events, the DTD may be written. This is controlled by
dtd_style:
`Ignore: No DOCTYPE clause is written`Include: The DOCTYPE clause is written, and the DTD is included
in the internal subset (the default)`Reference: The DOCTYPE clause is written as a reference to an
external DTDminimization: How to write out empty elements. `AllEmpty
means that all empty elements are minimized (using the <name/>
form). `None does not minimize at all and is the default.val display_events : ?dtd_style:dtd_style ->
?minimization:[ `AllEmpty | `None ] ->
Pxp_types.output_stream ->
Pxp_types.encoding ->
Pxp_types.rep_encoding -> (unit -> Pxp_types.event option) -> unitoutput_stream. The events must be encoded
as indicated by the rep_encoding argument, but the output is written
as specified by the encoding argument.
Namespace prefixes are declared as defined in the namespace scopes. Missing prefixes are invented on the fly.
The way the DTD is printed can be set as in write_events.
val string_of_event : Pxp_types.event -> string