package xtmpl

  1. Overview
  2. Docs

Module Rewrite.XSource

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

Constructors

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

Handling attributes

Sourceval get_att : attributes -> name -> attr_value option

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

Sourceval 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.

Sourceval 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.

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

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

Sourceval atts_remove : name -> attributes -> attributes

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

Sourceval 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.

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

Printers

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

Text extraction

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