The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

 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();
 $wow->setObject('user');
 $wow->setLanguage(XML::MetaGenerator::Language::Formula->new());

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

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

 # now collect the data
 $wow->collect();

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

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

DESCRIPTION

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

get_instance

returns the singleton MetaGenerator object

setCollector

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

setGenerator

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.

setLanguage

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).

setObject

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.

collect

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

template

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

generate

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

validate

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

AUTHOR

Riccardo Cambiassi <riccardo@infodrome.net>

SEE ALSO