* who wish to embed FOray in other applications.
*/
/* Instantiate the FOraySession. */
final SessionConfig sessionConfig = getOptions().getSessionConfig();
final FOraySession session = FOraySpecific.makeFOraySession(
sessionConfig);
/*
* Instantiate and configure the FOrayDocument(s). The constructor
* shown here is for regular SAX input.
* There is also a constructor for a DOM document, and another for a
* JAXP Transformer and Source.
* Multiple documents can be instantiated, and they will be processed
* in the order submitted.
*/
FOrayDocument document = null;
if (this.commandLineOptions.getInputMode()
== CommandLineOptions.INPUT_FO) {
document = new FOrayDocument(session, getInputSource(), null);
} else {
document = new FOrayDocument(session,
this.commandLineOptions.getXMLFile(),
this.commandLineOptions.getXSLFile());
}
/*
* Instantiate and configure the OutputTarget. The makeOutputTarget()
* method of FOrayTarget knows how to make most of the standard
* OutputTargets, but you can create and use a non-standard OutputTarget
* as well.
*/
final OutputTargetType outputType =
this.commandLineOptions.getOutputMode();
final OutputConfig outputOptions = this.getOutputConfig();
final FileOutputStream outputStream = getFileOutputStream();
final OutputTarget outputTarget = OutputTargetFactory.makeOutputTarget(
outputType, outputOptions, outputStream,
session.getLogger(), session.getGraphicServer());
/*
* Instantiate and configure the FOrayTarget(s). Multiple targets can
* be instantiated for each FOrayDocument, but right now only the first
* one is actually processed.
* LayoutStrategy is an optional parameter. Set it to null to have the
* system use the default.
* Targets that do not need an OutputStream should set that parameter
* to null.
*/
final LayoutStrategy layout = new PioneerLS(session.getLogger());
final FOrayTarget target = new FOrayTarget(document, outputTarget,
layout, outputStream);
/*
* Everything is now ready to go. There are two different processing
* models possible here. The first is to let FOray manage and
* complete the processing internally. The second is to manage that
* process externally, e.g. those integrating with Cocoon or another
* pipeline-type scheme. If you don't know which of those to use, you
* should probably let FOray control the processing. The instructions
* are separated below for the two models. IMPORTANT: Please note that
* the instructions reunify below for some cleanup code that is common
* to both.
*/
/* *****************************************************************************
* Start instructions for internal FOray control. Ignore this section
* if you are controlling externally.
* ****************************************************************************/
/*
* Just push the button, and let FOray do the rest ...
*/
session.process();
/* *****************************************************************************
* End instructions for internal FOray control.
* ****************************************************************************/