The gen_xml application

Copyright © 2024 Fred Youhanaie

Version: 0.1.0

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

Introduction

gen_xml is an Erlang bahaviour module for processing eXtensible Markup Language (XML) files.

Module Overview

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

The Callback Module

The callback module should export three functions for processing the individual XML elements:

Associated with each callback module is a state variable maintained by the gen_xml:read/3 function, and is initialized to the value that is supplied to it during the call. The current contents of the state variable is passed to the handler functions, which should return it, optionally updated, for the future calls to the handlers.

The structure of the state variable is entirely dependent on the callback module, for example the genxml_counter module will maintain a map where the keys are the XML element tags and the values are the cumulative counts of the corresponding tags.

Once read/3 has concluded processing the file, the final contents of the state variable is returned to the caller.

A number of sample callback modules have been provided in the Examples/ directory of the git repo.


Generated by EDoc