Module gen_xml

.

Copyright © 2024, Fred Youhanaie

Authors: Fred Youhanaie (fyrlang@anydata.co.uk).

Description

A set of functions to process XML files. See the overview doc for further details.

To start the process of parsing the XML file, the callback module should call the read/3 function. While read/3 is scanning the XML file it will call the appropriate handler functions.

The callback module should provide three callback functions:

All three callback handlers are passed the behaviour state, and should return the state, optionally updated.

Data Types

read_ret()

read_ret() = {fatal_error, term(), term(), term(), term()} | {ok, State::term()} | {error, Reason::term()}

Function Index

attr_map/1Return a map corresponding to the list of attributes from xmerl.
read/3Read in a valid XML file and process its elements using the supplied callback module.

Function Details

attr_map/1

attr_map(Attr::list()) -> map()

Return a map corresponding to the list of attributes from xmerl.

We extract the attribute names and values, and ignore the rest.

The attribute names are returned as atoms and the values as strings.

read/3

read(Filename::string(), CB_module::atom(), CB_state::term()) -> read_ret()

Read in a valid XML file and process its elements using the supplied callback module.

We expect the file to be a valid XML document, no validation is performed here. However, the supplied callback module can perform its own validation during the scan.

We return success/failure result. In case of success, the handler's final state is returned. The failure reason may originate from the xmerl_sax_parser module.


Generated by EDoc