package tyxml

  1. Overview
  2. Docs

Module Tyxml_xmlSource

Basic functions for construction and manipulation of XML tree.

include Xml_sigs.Iterable with type uri = string and type event_handler = string and type mouse_event_handler = string and type keyboard_event_handler = string and type touch_event_handler = string
include Xml_sigs.NoWrap with type uri = string with type event_handler = string with type mouse_event_handler = string with type keyboard_event_handler = string with type touch_event_handler = string
Sourcetype 'a wrap = 'a W.t
Sourcetype 'a list_wrap = 'a W.tlist
Sourcetype uri = string
Sourceval string_of_uri : (uri, string) W.ft
Sourceval uri_of_string : (string, uri) W.ft
Sourcetype aname = string
Sourcetype event_handler = string
Sourcetype mouse_event_handler = string
Sourcetype keyboard_event_handler = string
Sourcetype touch_event_handler = string
Sourcetype attrib
Sourceval float_attrib : aname -> float wrap -> attrib
Sourceval int_attrib : aname -> int wrap -> attrib
Sourceval string_attrib : aname -> string wrap -> attrib
Sourceval space_sep_attrib : aname -> string list wrap -> attrib
Sourceval comma_sep_attrib : aname -> string list wrap -> attrib
Sourceval event_handler_attrib : aname -> event_handler -> attrib
Sourceval mouse_event_handler_attrib : aname -> mouse_event_handler -> attrib
Sourceval keyboard_event_handler_attrib : aname -> keyboard_event_handler -> attrib
Sourceval touch_event_handler_attrib : aname -> touch_event_handler -> attrib
Sourceval uri_attrib : aname -> uri wrap -> attrib
Sourceval uris_attrib : aname -> uri list wrap -> attrib
Sourcetype elt
Sourcetype ename = string
Sourceval empty : unit -> elt
Sourceval comment : string -> elt
Sourceval pcdata : string wrap -> elt
Sourceval encodedpcdata : string wrap -> elt
Sourceval entity : string -> elt
Sourceval leaf : ?a:attrib list -> ename -> elt
Sourceval node : ?a:attrib list -> ename -> elt list_wrap -> elt
Sourceval cdata : string -> elt
Sourceval cdata_script : string -> elt
Sourceval cdata_style : string -> elt
Sourcetype separator =
  1. | Space
  2. | Comma
Sourceval aname : attrib -> aname
Sourcetype acontent = private
  1. | AFloat of float
  2. | AInt of int
  3. | AStr of string
  4. | AStrL of separator * string list
Sourceval acontent : attrib -> acontent
Sourcetype econtent = private
  1. | Empty
  2. | Comment of string
  3. | EncodedPCDATA of string
  4. | PCDATA of string
  5. | Entity of string
  6. | Leaf of ename * attrib list
  7. | Node of ename * attrib list * elt list
Sourceval content : elt -> econtent
include Xml_sigs.Pp with type elt := elt
Sourceval pp : ?encode:(string -> string) -> ?indent:bool -> unit -> Format.formatter -> elt -> unit

pp () is a Format printer for untyped XML.

It can be used in combination with "%a". For example, to get a string:

let s = Format.asprintf "%a" (pp ()) my_xml

A custom encoding function can be provided with the ~encode argument. Various implementations of encode are available in Xml_print.

Import/Export

Sourceval of_seq : Xml_stream.signal Seq.t -> elt list

Iterators

Sourceval amap : (ename -> attrib list -> attrib list) -> elt -> elt

Recursively edit attributes for the element and all its children.

Sourceval amap1 : (ename -> attrib list -> attrib list) -> elt -> elt

Edit attributes only for one element.

The following can safely be exported by higher level libraries, because removing an attribute from a element is always legal.

Sourceval rm_attrib : (aname -> bool) -> attrib list -> attrib list
Sourceval rm_attrib_from_list : (aname -> bool) -> (string -> bool) -> attrib list -> attrib list
Sourceval map_int_attrib : (aname -> bool) -> (int -> int) -> attrib list -> attrib list
Sourceval map_string_attrib : (aname -> bool) -> (string -> string) -> attrib list -> attrib list
Sourceval map_string_attrib_in_list : (aname -> bool) -> (string -> string) -> attrib list -> attrib list

Exporting the following by higher level libraries would drive a hole through a type system, because they allow to add any attribute to any element.

Sourceval add_int_attrib : aname -> int -> attrib list -> attrib list
Sourceval add_string_attrib : aname -> string -> attrib list -> attrib list
Sourceval add_comma_sep_attrib : aname -> string -> attrib list -> attrib list
Sourceval add_space_sep_attrib : aname -> string -> attrib list -> attrib list
Sourceval fold : (unit -> 'a) -> (string -> 'a) -> (string -> 'a) -> (string -> 'a) -> (string -> 'a) -> (ename -> attrib list -> 'a) -> (ename -> attrib list -> 'a list -> 'a) -> elt -> 'a
Sourceval all_entities : elt -> string list
Sourceval translate : (ename -> attrib list -> elt) -> (ename -> attrib list -> elt list -> elt) -> ('state -> ename -> attrib list -> elt list) -> ('state -> ename -> attrib list -> elt list -> elt list) -> (ename -> attrib list -> 'state -> 'state) -> 'state -> elt -> elt

Deprecated printers

Sourceval print_list : output:(string -> unit) -> ?encode:(string -> string) -> elt list -> unit
  • deprecated Use Xml.pp instead.
Sourceval print : Format.formatter -> elt -> unit
  • deprecated Use Xml.pp instead.
OCaml

Innovation. Community. Security.