cow

Caml on the Web
IN THIS PACKAGE
Module Cow . Xml
include module type of Xmlm
type encoding = [
| `ISO_8859_1
| `US_ASCII
| `UTF_16
| `UTF_16BE
| `UTF_16LE
| `UTF_8
]
type dtd = string option
type name = string * string
type attribute = name * string
type tag = name * attribute list
type signal = [
| `Data of string
| `Dtd of dtd
| `El_end
| `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 = [
| `Expected_char_seqs of string list * string
| `Expected_root_element
| `Illegal_char_ref of string
| `Illegal_char_seq of string
| `Malformed_char_stream
| `Max_buffer_size
| `Unexpected_eoi
| `Unknown_encoding of string
| `Unknown_entity_ref of string
| `Unknown_ns_prefix of string
]
val error_message : error -> string
exception Error of pos * error
type source = [
| `Channel of Pervasives.in_channel
| `Fun of unit -> int
| `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 = [
| `Data of string
| `El of tag * 'a list
]
type dest = [
| `Buffer of Buffer.t
| `Channel of Pervasives.out_channel
| `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