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).
The generate element introduces the use of a generator in a process body. Its structure is the following:
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:
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
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.
The serialize element introduces the use of a serializer in a process body. Its structure is the following:
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:
Serializing enables, for instance, reading a file from the file system or the Internet. It can also generate XML from a database.
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
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