package yocaml_syndication

  1. Overview
  2. Docs

Tool for structuring (and printing) XML, used as a basis for describing XML nodes. The implementation is rather naive, but its purpose is simply to describe syndication flows, hence the "simplicity of the implementation".

The first version lived in the Yocaml package and was based on an imoderate use of existentials.

Attributes

Compose with XML attributes in the form `key="value"`.

module Attr : sig ... end

An attribute is an association between a key and a value (quoted). Please note that this library does not guarantee that the key or value is correctly formatted, and it is the user's responsibility to produce only correct values.

Nodes

Description of XML nodes (or leaves).

Types

type node

Describes an XML node. An XML tree can be described by a node (a branch made up of branches) or by a leaf (a branch containing a PCDATA character string).

type t

Describes an XML document.

API

val document : ?version:string -> ?encoding:string -> ?standalone:bool -> node -> t

Create a complete XML document.

val leaf : ?indent:bool -> ?ns:string -> name:string -> ?attr:Attr.t list -> string option -> node

Describes a node that only contains PCDATA.

val cdata : string -> string option

cdata txt compose with leaf to allow special chars.

val escape : string -> string option

escape txt compose with leaf to escape special chars.

val node : ?ns:string -> name:string -> ?attr:Attr.t list -> node list -> node

Describesa node that contains nested nodes.

val namespace : ns:string -> node -> node

namespace ~ns node adds a namespace to the node and every node children.

val opt : node option -> node

opt node conditionnally adds node.

val may : ('a -> node) -> 'a option -> node

may f x Lift a value into a node if it exists.

val may_leaf : ?indent:bool -> ?finalize:(string -> string option) -> name:string -> ('a -> string) -> 'a option -> node

may_leaf ~name f x May build a leaf.

val to_string : t -> string

Pretty printer for XML document.

OCaml

Innovation. Community. Security.