Tyxml_xml
tyxml · API reference
Basic functions for construction and manipulation of XML tree.
module W = Xml_wrap.NoWraptype 'a wrap = 'a W.ttype 'a list_wrap = 'a W.tlisttype uri = stringval string_of_uri : (uri, string) W.ftval uri_of_string : (string, uri) W.fttype aname = stringtype event_handler = stringtype mouse_event_handler = stringtype keyboard_event_handler = stringtype touch_event_handler = stringtype attribval float_attrib : aname -> float wrap -> attribval int_attrib : aname -> int wrap -> attribval string_attrib : aname -> string wrap -> attribval space_sep_attrib : aname -> string list wrap -> attribval comma_sep_attrib : aname -> string list wrap -> attribval event_handler_attrib : aname -> event_handler -> attribval mouse_event_handler_attrib : aname -> mouse_event_handler -> attribval keyboard_event_handler_attrib : aname -> keyboard_event_handler -> attribval touch_event_handler_attrib : aname -> touch_event_handler -> attribval uri_attrib : aname -> uri wrap -> attribval uris_attrib : aname -> uri list wrap -> attribtype elttype ename = stringval empty : unit -> eltval comment : string -> eltval pcdata : string wrap -> eltval encodedpcdata : string wrap -> eltval entity : string -> eltval leaf : ?a:attrib list -> ename -> eltval node : ?a:attrib list -> ename -> elt list_wrap -> eltval cdata : string -> eltval cdata_script : string -> eltval cdata_style : string -> elttype separator =
| Space
| Commaval aname : attrib -> anametype acontent = private
| AFloat of float
| AInt of int
| AStr of string
| AStrL of separator * string listval acontent : attrib -> acontenttype econtent = private
| Empty
| Comment of string
| EncodedPCDATA of string
| PCDATA of string
| Entity of string
| Leaf of ename * attrib list
| Node of ename * attrib list * elt listval content : elt -> econtentval pp :
?encode:(string -> string) ->
?indent:bool ->
unit ->
Format.formatter ->
elt ->
unitpp () 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_xmlA custom encoding function can be provided with the ~encode argument. Various implementations of encode are available in Xml_print.
Import/Export
val of_seq : Xml_stream.signal Seq.t -> elt listIterators
val amap : (ename -> attrib list -> attrib list) -> elt -> eltRecursively edit attributes for the element and all its children.
val amap1 : (ename -> attrib list -> attrib list) -> elt -> eltEdit 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.
val rm_attrib : (aname -> bool) -> attrib list -> attrib listval rm_attrib_from_list :
(aname -> bool) ->
(string -> bool) ->
attrib list ->
attrib listval map_int_attrib :
(aname -> bool) ->
(int -> int) ->
attrib list ->
attrib listval map_string_attrib :
(aname -> bool) ->
(string -> string) ->
attrib list ->
attrib listval map_string_attrib_in_list :
(aname -> bool) ->
(string -> string) ->
attrib list ->
attrib listExporting the following by higher level libraries would drive a hole through a type system, because they allow to add any attribute to any element.
val add_int_attrib : aname -> int -> attrib list -> attrib listval add_string_attrib : aname -> string -> attrib list -> attrib listval add_comma_sep_attrib : aname -> string -> attrib list -> attrib listval add_space_sep_attrib : aname -> string -> attrib list -> attrib listval fold :
(unit -> 'a) ->
(string -> 'a) ->
(string -> 'a) ->
(string -> 'a) ->
(string -> 'a) ->
(ename -> attrib list -> 'a) ->
(ename -> attrib list -> 'a list -> 'a) ->
elt ->
'aval all_entities : elt -> string listval 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 ->
eltDeprecated printers
val print_list :
output:(string -> unit) ->
?encode:(string -> string) ->
elt list ->
unitdeprecated Use Xml.pp instead.
val print : Format.formatter -> elt -> unitdeprecated Use Xml.pp instead.