Module Yaxposax


module Yaxposax: sig .. end
Provides a SAX-like interface, where the parser invokes user callbacks as it processes a document.


Definition of callbacks


type xml_callbacks = {
   start_element : Yaxpo.qname -> Yaxpo.att list -> (unit -> unit) -> unit;
   characters : string -> (unit -> unit) -> unit;
   cdata : string -> (unit -> unit) -> unit;
   comment : string -> (unit -> unit) -> unit;
   pi : string -> string -> (unit -> unit) -> unit;
   end_element : Yaxpo.qname -> (unit -> unit) -> unit;
}
Each field should be set to a function that will be invoked when the corresponding token is parsed from the XML data.

The callbacks are invoked in continuation-passing style (CPS). They are each passed an additional argument besides what you expect, a procedure of type (unit->unit). When your callback is finished processing, instead of returning control, it should issue a tail-call to this procedure.


Parsing routines

val parse_element : #Cps_reader.t -> xml_callbacks -> (unit -> unit) -> unit
Parse the next element from the reader. Accepts a Cps_reader.t, your callbacks, and a continuation. In most cases, you can use (fun () -> ()) for the continuation.
Raises
val parse_document : #Cps_reader.t -> xml_callbacks -> (unit -> unit) -> unit
Parse a document (consisting of some comments and PIs followed by a document element)
Raises