exsom v0.2.1 Exsom

Exsom is a thin wrapper around the erlsom XML parsing library. Much of the documentation has been taken from the erlsom documentation, as they are obviously equivalent.

Changes from erlsom

Many functions have been renamed and/or broken into modules. A user should only need to import the modules that they need, and have it be very readable.

The most common functions get exposed as defaults in the parent module.

Summary

Types

Internal representation of a XML document

Internal representation of a XSD document

Relative path, relative from project root

A list of characters that follow after the end of the XML document

Functions

Translates a structure of records to an XML document. It is the inverse of scan The output option can be used to specify the format of the output. The possible values are

Parses a XML document, that conforms to a given XSD schema, into an internal representation of a XML document (ie. Exsom.instance)

Translate the XML document to a generic data structure based on n-tuples

Types

binary_xml :: binary
binary_xsd :: binary
charlist_xml :: charlist
charlist_xsd :: charlist
instance :: struct

Internal representation of a XML document

model :: any

Internal representation of a XSD document

parse_error :: map
parse_failure :: {:error, parse_error}
relative_path :: String.t

Relative path, relative from project root

rest :: charlist

A list of characters that follow after the end of the XML document

simple_format_element :: {tag :: any, attributes :: any, content :: any}
simple_format_option ::
  {:nameFun, (any, any, any -> any)} |
  {:output_encoding, :utf8}

Functions

compose(struct, model, opts \\ [])

Specs

compose(struct :: Exsom.instance, model :: Exsom.model, opts :: [{:output, atom}]) :: {atom, Exsom.xml}

Translates a structure of records to an XML document. It is the inverse of scan The output option can be used to specify the format of the output. The possible values are:

AtomMeaning
:charlist[DEFAULT] List of Unicode code points (integers)
:chardataDeep list of Unicode code points and UTF-8 encoded binaries
:binaryUTF-8 encoded binary
parse(xml, model, opts \\ [])

Specs

parse(xml :: Exsom.xml, model :: Exsom.model, opts :: list) ::
  Exsom.parse_success |
  Exsom.parse_failure

Parses a XML document, that conforms to a given XSD schema, into an internal representation of a XML document (ie. Exsom.instance).

Returns either {:ok, Struct, Rest} or {:error, Error}. Error has the following structure:

%{
  exception: Exception,   # the exception that was thrown by the program
  stack: Stack,           # representation of the 'stack' that is maintained by `erlsom`
  received: Event         # the SAX event that `erlsom` was processing when it ran into problems
}
simple_format(xml, opts \\ [])

Specs

simple_format(raw_xml, [simple_format_option]) ::
  simple_format_ok |
  {:error, String.t}

Translate the XML document to a generic data structure based on n-tuples.