Generators and serialisers

When a transformation flow takes input from a source which is not a stream (file, network, database...) or must output some information directly to such a location, there is a need for basic "transformations" achieving this simple task. This is useful when generating a full web site from source elements.

Generators (and serializers) are the most basic built-in components. They are transformations with no input and one output (and one input and no output respectively).

 [ generator icon ]


XML declaration

The generate element introduces the use of a generator in a process body. Its structure is the following:

<generate type="type" id="id" out="channel"> {<with-param>}* </generate>

In the bibliographic example, the transformation flows always get their data from files bibexmo.xml and je.xml. These files are read through the use of the generate element:

<generate type="readfile" id="bibexmo" out="R1"/> <with-param name="file">biblio/bibexmo.xml</with-param> </generate> <generate type="readfile" id="je" out="R2"/> <with-param name="file">biblio/je.xml</with-param> </generate>

Built-in generators

Transmorpher offers the readfile built-in generator which reads an XML file or an URL (identified through a file parameter and output the SAX events corresponding to its content.

References to contributed generators can be found here

Manipulation API

Extension API

A generator extends the fr.fluxmedia.transmorpher.TProcessFactory.TReader class. It will be connected to the next SAX handler (contained in its attribute) to which it must send the SAX events generated.

In addition, TReader implements the Runnable class. This means that the generators must provide the execProcess() and run() methods. TO BE COMPLETED.  [ serializer icon


XML declaration

The serialize element introduces the use of a serializer in a process body. Its structure is the following:

<serialize type="type" id="id" in="channel"> {<with-param>}* </serialize>

In the bibliographic example, the transformation flows always output its results to the files biblio.html, biblio.bib, biblio-xml.html and tb-biblio.html via the serialize elements:

<serialize type="writefile" id="writeHTML" in="X31"/> <with-param name="file">biblio/biblio.xml</with-param> </serialize> <serialize type="writefile" id="writeBIB" in="Y31"/> <with-param name="file">biblio/biblio.bib</with-param> </serialize> <serialize type="writefile" id="writeXML" in="Z31"/> <with-param name="file">biblio/biblio.xml</with-param> </serialize> <serialize type="writefile" id="writeTB" in="W3"/> <with-param name="file">biblio/biblio_tb.html</with-param> </serialize>

Serializing enables, for instance, reading a file from the file system or the Internet. It can also generate XML from a database.

Built-in serializers

Transmorpher provides built-in serializers for writing XML in a file (writefile which takes a file parameter identifying this file) or for writting to standard output (stdout). Both serializers takes additionnal parameters corresponding to the attributes of an xsl:output element:

References to contributed extensions can be found here

Manipulation API

Extension API

A serializer extends the fr.fluxmedia.transmorpher.TProcessFactory.TSerializer class. It must implement a SAX ContentHandler and serialize the SAX events the appropriate way. This handler will be called directly by the process connected by the input channel.

Next chapter: Dispatchers

Feel free to comment to Jérôme:Euzenat#inrialpes:fr, $Id: generators.html,v 1.6 2005/10/25 13:34:00 euzenat Exp $