The dispatcher is an element that has one input and many outputs. It can be used for broadcasting the input to several channels or to selectively separate some elements from others.
The dispatch element introduces the use of a dispatcher in a process body. Its structure is the following:
Transmorpher provides a basic implementation of a dispatcher (broadcast), its behavior is to copy the input to the different outputs. It is used in the bibliography example for dispatching the input:
Figure: Basic dispatcher
Transmorpher provides an other implementation of a dispatcher (TestingDispatcher), its behavior is to send the input to the first ouput if test==value, to the other if test is test!=value:
References to contributed extensions can be found here
One can imagine more complex dispatchers. In the bibliography example, a dispatcher could split the reference elements into a regular list of references and the list of authors. This can be useful for generating a list of authors (sorted and uniq'ed) or an index. In the transformation of this paper from XML to HTML, we could have separated the graphic elements from the rest of this paper in order to transform the TIFF pictures into JPEG.
Figure: Complex dispatcher
Implementing new dispatchers can be achieved by extending the fr.fluxmedia.transmorpher.TProcessFactory.TDispatcher class. This class extends the org.xml.sax.ContentHandler interface which must be implemented in your class. This means that the SAX events arriving by the input channel must be handled by the new class.
Moreover, the class will have to communicate to the handlers that implements the output channels the SAX events that you want to send to them (at least, startDocument and endDocument). These content handlers are found in the contentHandlers variable (the content handler corresponding to output of rank i by contentHandlers[i]).
The merger is a process that has several inputs and one output.
The merge element introduces the use of a merger in a process body. Its structure is the following:
Transmorpher provides two simple built-in mergers. concat is a simple merger that copies all the 2..n channels under the root element of the first channel (preserving order). This merger is used in the bibliography example for merging two source XML documents:
Figure: Basic merger
A second merger, wrap wraps the tree corresponding of all its input channels under a wrapping tag which will be the root element of the output channel. It thus takes a tag parameter containing the name of this root element.
References to contributed extensions can be found here
One can imagine more complex mergers. For instance, in the bibliography example, one can define a merger which merges a channel of titles with a channel of authors to produce a channel of references.
Figure: complex
merger
New mergers must extend the fr.fluxmedia.transmorpher.TProcessFactory.TMerger class. This class must provide handlers for handling input channels and send resulting SAX events to the handler of the output channel. TO BE COMPLETED, THIS IS MORE COMPLICATED.
Next chapter: External processes