XML::MetaGenerator - Collects user input, validates input and generates output in a number of ways based on the defined grammar.


 use XML::MetaGenerator;
 use XML::MetaGenerator::Language::Formula;
 use XML::MetaGenerator::Language::Formula::Collector::ReadLine;
 use XML::MetaGenerator::Language::Formula::Generator::HTML;

 my $wow = XML::MetaGenerator->get_instance();

 my $input = XML::MetaGenerator::Language::Formula::Collector::ReadLine->new();

 my $generator = XML::MetaGenerator::Language::Formula::Generator::HTML->new();

 # now collect the data

 # validate it
 my ($valids, $missings, $invalids)= $wow->validate();

 # generate a document from the collected data;
 my $page =  $wow->generate();


This object will work with many kinds of XML specification languages (RELAX, xml-scheme, Formula and so on), using them to catch ('collect') input data from different sources (cgi, command line, files ...), 'validate' it and eventually transforming it into the desired format (e.g. HTML, XML). I use this in order to have a common API for applications that require multiple media access (e.g. WWW and console).

Object methods

These are the public methods available from MetaGenerator objects


returns the singleton MetaGenerator object


This let the user choose what kind of collector will be used. The only parameter is a XML::MetaGenerator::Collector object. XML::MetaGenerator comes with three prepackaged collectors: Apache - read data from $r params Environment - read data from %ENV ReadLine - read data from terminal using Term::ReadLine


This let the user choose what kind of output to generate. The parameter is a XML::MetaGenerator::Generator object. The package comes with two prepackaged generator: SimpleHTML - generate a html document consisting of a table with one row for every element in the formula; Also, if the data was validated before calling the generator, invalid elements will be highlighted. XML - generate a basic xml document with XML::Writer.


This method lets the user choose what kind of grammar to use for validation. Currently XML::MetaGenerator supports just the formula language, for more information on it, refer to XML::MetaGenerator::Formula(3). I hope to be able to add more languages soon (e.g. RELAX and xml-schema).


This set the type of objects that MetaGenerator is going to manipulate. The formulae directory holds some sample objects defined through the formula markup language.


This is the input method for MetaGenerator. It uses the Collector object to get the data from the right input source


This method outputs a dummy object. It's useful for testing or when you have to show how that object will look like.


This method is used to parse the collected input and to output the desired object in the desired format.


This method validates the input and returns an hash containing valids, invalids and missing elements.


Riccardo Cambiassi <>