package xtmpl

  1. Overview
  2. Docs
type name
type attr_value
type attributes
type data
type proc_inst = {
  1. loc : loc option;
  2. app : name;
  3. args : string;
}
type xml_decl = {
  1. loc : loc option;
  2. atts : attributes;
}
type doctype = {
  1. loc : loc option;
  2. name : name;
  3. args : string;
}
type node = {
  1. loc : loc option;
  2. name : name;
  3. atts : attributes;
  4. subs : tree list;
  5. data : data;
}
and tree =
  1. | E of node
  2. | D of cdata
  3. | C of comment
  4. | PI of proc_inst
type prolog_misc =
  1. | PC of comment
  2. | PPI of proc_inst
type prolog = {
  1. decl : xml_decl option;
  2. misc : prolog_misc list;
  3. doctype : doctype option;
}
type doc = {
  1. prolog : prolog;
  2. elements : tree list;
}
val compare_doc : doc -> doc -> int
val compare_tree : tree -> tree -> int

Constructors

val node_ : ?loc:loc -> name -> ?atts:attributes -> ?data:data -> tree list -> node
val node : ?loc:loc -> name -> ?atts:attributes -> ?data:data -> tree list -> tree
val cdata_ : ?loc:loc -> ?quoted:bool -> string -> cdata
val cdata : ?loc:loc -> ?quoted:bool -> string -> tree
val comment_ : ?loc:loc -> string -> comment
val comment : ?loc:loc -> string -> tree
val prolog_comment : ?loc:loc -> string -> comment
val pi_ : ?loc:loc -> name -> string -> proc_inst
val pi : ?loc:loc -> name -> string -> tree
val prolog_pi : ?loc:loc -> name -> string -> proc_inst
val xml_decl : ?loc:loc -> attributes -> xml_decl
val doctype : ?loc:loc -> name -> string -> doctype
val prolog : ?decl:xml_decl -> ?doctype:doctype -> prolog_misc list -> prolog
val doc : prolog -> tree list -> doc
val doc_empty : unit -> doc

Handling attributes

val get_att : attributes -> name -> attr_value option

get_att atts name returns the value associated to given attribute, if any.

val opt_att : attributes -> ?def:attr_value -> name -> attr_value

opt_att atts ?def name returns the value associated to given attribute, or the default value specified by ?def. If def is not specified, P.default_attr_value is used.

val atts_of_list : ?atts:attributes -> (name * attr_value) list -> attributes

atts_of_list list returns a attributes structure from the given list of pairs (name, value) ; (name, value) ; ....

  • parameter atts

    can be used to specify an existing attributes structure to add bindings to, instead of starting from an empty one.

val atts_one : ?atts:attributes -> name -> attr_value -> attributes

atts_one ?atts name value is like atts_of_list but for one attribute.

val atts_remove : name -> attributes -> attributes

atts_remove name attributes removes the binding to name from the attributes.

val atts_replace : name -> attr_value -> attributes -> attributes

atts_replace name value attributes adds a new bindings from name to value in attributes. If name was previously bound, the previous binding is removed.

val atts_fold : (name -> attr_value -> 'acc -> 'acc) -> attributes -> 'acc -> 'acc
val atts_empty : unit -> attributes

Printers

val pp_doc : Format.formatter -> doc -> unit
val pp : Format.formatter -> doc -> unit
val pp_attr : ?first:bool -> Format.formatter -> name -> attr_value -> unit
val pp_attributes : Format.formatter -> attributes -> unit
val pp_trees : Format.formatter -> tree list -> unit
val doc_to_string : doc -> string
val to_string : tree list -> string
val string_of_xml : tree -> string

Text extraction

val doctype_name : doc -> name option
val text_of_xmls : tree list -> string
val text_of_range : tree -> tree -> tree option -> string
OCaml

Innovation. Community. Security.