package cow

  1. Overview
  2. Docs

XML combinators.

include module type of Xmlm
type encoding = [
  1. | `ISO_8859_1
  2. | `US_ASCII
  3. | `UTF_16
  4. | `UTF_16BE
  5. | `UTF_16LE
  6. | `UTF_8
]
type dtd = string option
type name = string * string
type attribute = name * string
type tag = name * attribute list
type signal = [
  1. | `Data of string
  2. | `Dtd of dtd
  3. | `El_end
  4. | `El_start of tag
]
val ns_xml : string
val ns_xmlns : string
val pp_dtd : Format.formatter -> dtd -> unit
val pp_name : Format.formatter -> name -> unit
val pp_attribute : Format.formatter -> attribute -> unit
val pp_tag : Format.formatter -> tag -> unit
val pp_signal : Format.formatter -> signal -> unit
type pos = int * int
type error = [
  1. | `Expected_char_seqs of string list * string
  2. | `Expected_root_element
  3. | `Illegal_char_ref of string
  4. | `Illegal_char_seq of string
  5. | `Malformed_char_stream
  6. | `Max_buffer_size
  7. | `Unexpected_eoi
  8. | `Unknown_encoding of string
  9. | `Unknown_entity_ref of string
  10. | `Unknown_ns_prefix of string
]
val error_message : error -> string
exception Error of pos * error
type source = [
  1. | `Channel of Pervasives.in_channel
  2. | `Fun of unit -> int
  3. | `String of int * string
]
type input
val make_input : ?enc:encoding option -> ?strip:bool -> ?ns:(string -> string option) -> ?entity:(string -> string option) -> source -> input
val input : input -> signal
val input_tree : el:(tag -> 'a list -> 'a) -> data:(string -> 'a) -> input -> 'a
val input_doc_tree : el:(tag -> 'a list -> 'a) -> data:(string -> 'a) -> input -> dtd * 'a
val peek : input -> signal
val eoi : input -> bool
val pos : input -> pos
type !'a frag = [
  1. | `Data of string
  2. | `El of tag * 'a list
]
type dest = [
  1. | `Buffer of Buffer.t
  2. | `Channel of Pervasives.out_channel
  3. | `Fun of int -> unit
]
type output
val make_output : ?decl:bool -> ?nl:bool -> ?indent:int option -> ?ns_prefix:(string -> string option) -> dest -> output
val output : output -> signal -> unit
val output_depth : output -> int
val output_tree : ('a -> 'a frag) -> output -> 'a -> unit
val output_doc_tree : ('a -> 'a frag) -> output -> (dtd * 'a) -> unit
type std_string = string
type std_buffer = Buffer.t
module type String = sig ... end
module type Buffer = sig ... end
module type S = sig ... end
module Make (String : String) (Buffer : sig ... end) : sig ... end
type t = 'a frag as 'a frag list

The type for XML fragments.

val to_string : ?decl:bool -> t -> string
val of_string : ?entity:(string -> string option) -> ?enc:encoding -> string -> t

of_string s returns the XML tree described by s.

  • parameter entity

    is called to resolve non predefined entity references such as "&". It must return an UTF-8 string corresponding to the replacement character data. By default, only predefined entities, i.e., "<", ">", "&", "'", and """, are recognized.

  • parameter enc

    The encoding of the document. Default None which means that one does not know the encoding.

Combinators

val empty : t

empty is the empty XML fragment.

val string : string -> t

string s is the XML fragment s.

val int : int -> t

int i is the XML fragment i.

val float : float -> t

float f is the XML fragment f.

val list : t list -> t

list xs is the XML fragment x1 ... xn.

val some : t option -> t

some t is t if it's not empty, empty otherwise.

val uri : Uri.t -> t

uri t is t.

val tag : string -> ?attrs:(string * string) list -> t -> t

tag k v is <k>v</k>

val tago : string -> ?attrs:(string * string) list -> t option -> t

tago k v is k v if v is not None, otherwise it's empty.

val (++) : t -> t -> t

x ++ y is x y