package xtmpl

  1. Overview
  2. Docs
Xml templating library

Install

Dune Dependency

Authors

Maintainers

Sources

xtmpl-0.19.0.tar.gz
md5=398055f25eeac6972b0094dbfb3a6d8d
sha512=d0ab7fe67f2534a5c91d9c7e55efbcbcb4fa9269cfa2016e5793efbfe76abe33d3dac28eb44cfb940f121d167b88b14a0d3ba042bbd53a5d4dd379c27fae2328

doc/xtmpl/Xtmpl/Xml/index.html

Module Xtmpl.XmlSource

Regular XML trees

Sourcemodule SMap : Map.S with type key = string

Locations

Sourcetype pos = {
  1. line : int;
  2. bol : int;
  3. char : int;
  4. file : string option;
}

A position in a source (file, string, ...).

Sourceval pos : ?file:string -> line:int -> bol:int -> char:int -> unit -> pos
Sourcetype loc = {
  1. loc_start : pos;
  2. loc_stop : pos;
}

A location is a range defined by two positions.

Sourceval string_of_loc : loc -> string
Sourceval loc_sprintf : loc option -> ('a, unit, string) format -> 'a
Sourcetype 'a with_loc = 'a * loc option
Sourceval loc : pos -> pos -> loc

loc loc_start loc_stop creates a loc structure with the given positions.

Errors

Sourcetype error = loc * string
Sourceexception Error of error
Sourceval error : loc -> string -> 'a
Sourceval string_of_error : (loc * string) -> string

Names

Sourcetype name = string * string
Sourceval string_of_name : (string * string) -> string
Sourceval name_of_string : string -> string * string

name_of_string str cuts a name according to first ':' character. If no such character is found, return ("",str).

Sourcemodule Name_ord : Map.OrderedType with type t = name
Sourcemodule Name_map : Map.S with type key = name
Sourcemodule Name_set : Set.S with type elt = name
Sourcemodule SSet : Set.S with type elt = string

XML trees

Sourcetype cdata = {
  1. loc : loc option;
  2. text : string;
  3. quoted : bool;
}
Sourcetype comment = {
  1. loc : loc option;
  2. comment : string;
}
Sourcetype proc_inst = {
  1. loc : loc option;
  2. app : name;
  3. args : string;
}
Sourcetype 'a attributes = 'a Name_map.t
Sourcetype str_attributes = string with_loc attributes
Sourcetype xml_decl = {
  1. loc : loc option;
  2. atts : str_attributes;
}
Sourcetype doctype = {
  1. loc : loc option;
  2. name : name;
  3. args : string;
}
Sourcetype node = {
  1. loc : loc option;
  2. name : name;
  3. atts : str_attributes;
  4. subs : tree list;
}
Sourceand tree =
  1. | E of node
  2. | D of cdata
  3. | C of comment
  4. | PI of proc_inst
Sourcetype prolog_misc =
  1. | PC of comment
  2. | PPI of proc_inst
Sourcetype prolog = {
  1. decl : xml_decl option;
  2. misc : prolog_misc list;
  3. doctype : doctype option;
}
Sourcetype 'a doc = {
  1. prolog : prolog;
  2. elements : 'a list;
}

Constructors

Sourceval node : ?loc:loc -> name -> ?atts:str_attributes -> tree list -> tree
Sourceval cdata : ?loc:loc -> ?quoted:bool -> string -> tree
Sourceval comment : ?loc:loc -> string -> tree
Sourceval prolog_comment : ?loc:loc -> string -> prolog_misc
Sourceval pi : ?loc:loc -> name -> string -> tree
Sourceval prolog_pi : ?loc:loc -> name -> string -> prolog_misc
Sourceval xml_decl : ?loc:loc -> str_attributes -> xml_decl
Sourceval doctype : ?loc:loc -> name -> string -> doctype
Sourceval prolog : ?decl:xml_decl -> ?doctype:doctype -> prolog_misc list -> prolog
Sourceval doc : prolog -> tree list -> tree doc
Sourceval merge_cdata : cdata -> cdata -> cdata
Sourceval doctype_name : 'a doc -> name option

Input/output

Sourcetype parse_param = {
  1. ignore_unclosed : bool;
    (*

    auto-close unclosed elements

    *)
  2. self_closing : SSet.t;
    (*

    self-closing elements

    *)
  3. entities : Uchar.t SMap.t;
    (*

    entity references to unescape to utf-8 chars

    *)
}
Sourceval default_parse_param : parse_param

Default: no self-closing tags, unescape XML entities (amp, apos,quot, lt, gt). ignore_unclosed: false.

Sourceval xml_entities : Uchar.t SMap.t

mapping from XML entities to utf-8 code points

Sourceval html_entities : Uchar.t SMap.t

mapping from XML entities to utf-8 code points

mapping from HTML entities to utf-8 code points

Sourceval unescape : parse_param -> ?entities:bool -> string -> string

Unescape character references and entity references from parse_param.entities.

  • parameter entities

    can be set to false not to unescape entity references.

Sourceval escape : ?quotes:bool -> string -> string

Replace the following characters: < by &lt;, > by &gt;, & by &amp;. Also replace simple and double quotes by &apos; and &quot; if quotes = true (which is false by default).

Sourceval from_string : ?param:parse_param -> ?pos_start:pos -> string -> tree list
Sourceval from_channel : ?param:parse_param -> ?pos_start:pos -> in_channel -> tree list
Sourceval from_file : ?param:parse_param -> string -> tree list
Sourceval doc_from_string : ?param:parse_param -> ?pos_start:pos -> string -> tree doc
Sourceval doc_from_channel : ?param:parse_param -> ?pos_start:pos -> in_channel -> tree doc
Sourceval doc_from_file : ?param:parse_param -> string -> tree doc
Sourceval to_string : tree list -> string
Sourceval doc_to_string : tree doc -> string

Attributes

Sourceval atts_empty : 'a attributes
Sourceval atts_of_list : ?atts:'a attributes -> (name * 'a) list -> 'a attributes

Same as Rewrite.atts_of_list but for generic attributes.

Sourceval atts_one : ?atts:'a attributes -> name -> 'a -> 'a attributes

Same as Rewrite.atts_one but for generic attributes.

Sourceval atts_remove : name -> 'a attributes -> 'a attributes

Same as Rewrite.atts_remove but for generic attributes.

Sourceval atts_replace : name -> 'a -> 'a attributes -> 'a attributes

Same as Rewrite.atts_replace but for generic attributes.

Sourceval get_att : 'a attributes -> name -> 'a option

Same as Rewrite.get_att but for generic attributes.

Sourceval opt_att : str_attributes -> ?def:string -> name -> string * loc option
Sourceval string_of_atts : str_attributes -> string

Return a string representation of the given str_attributes.

OCaml

Innovation. Community. Security.