package ocsigenserver

  1. Overview
  2. Docs

This modules contains types and constructor for the description of XML configurations and the accordingly parsing.

type element

Specification of a XML element.

type attribute

Specification of a XML attribute.

val element : name:string -> ?obligatory:bool -> ?init:(unit -> unit) -> ?elements:element list -> ?attributes:attribute list -> ?pcdata:(string -> unit) -> ?other_elements:(string -> (string * string) list -> Xml.xml list -> unit) -> ?other_attributes:(string -> string -> unit) -> unit -> element

Create the specification of a XML element.

  • parameter name

    Name of the XML tag

  • parameter init

    A function to be executed before processing the child elements and attributes

  • parameter obligatory

    Whether the element is obligatory (false by default)

  • parameter elements

    Specifications of the child elements

  • parameter attribute

    Specifications of the attributes

  • parameter pcdata

    Function to be applied on the pcdata (ignore_blank_pcdata by default)

  • parameter other_elements

    Optional function to be applied on the content of unspecified tags

  • parameter other_attributes

    Optional function to be applied on the unspecfied attributes

val attribute : name:string -> ?obligatory:bool -> (string -> unit) -> attribute

attribute ~name f create a specification of a XML attribute.

  • parameter name

    The name of the XML attribute

  • parameter obligatory

    Whether the attribute is obligatory (false by default)

  • parameter f

    Function to be applied on the value string of the attribute

val process_element : in_tag:string -> elements:element list -> ?pcdata:(string -> unit) -> ?other_elements:(string -> (string * string) list -> Xml.xml list -> unit) -> Xml.xml -> unit

Process an XML element by the specifications.

  • parameter in_tag

    Name of the enclosing XML tag (just for generating error messages)

  • parameter elements

    Specifications of the child elements

  • parameter pcdata

    Function to be applied on the PCDATA (ignore_blank_pcdata by default)

  • parameter other_elements

    Optional function to be applied on unexpected child elements

  • raises Error_in_config_file

    If an element (resp. attribute) occurs which is not specified by the element (resp. attribute) parameter and no function other_elements (resp. other_attributes) is provided

val process_elements : in_tag:string -> elements:element list -> ?pcdata:(string -> unit) -> ?other_elements:(string -> (string * string) list -> Xml.xml list -> unit) -> ?init:(unit -> unit) -> Xml.xml list -> unit

Application of process_element on a list of XML elements.

val ignore_blank_pcdata : in_tag:string -> string -> unit

The specification for ignoring blank PCDATA ('\n', '\r', ' ', '\t') and failing otherwise (a reasonable default).

val refuse_pcdata : in_tag:string -> string -> unit
OCaml

Innovation. Community. Security.