Package org.apache.fop.cli
Class InputHandler
java.lang.Object
org.apache.fop.cli.InputHandler
- All Implemented Interfaces:
ErrorListener
,Renderable
- Direct Known Subclasses:
AreaTreeInputHandler
,IFInputHandler
,ImageInputHandler
Class for handling files input from command line
either with XML and XSLT files (and optionally xsl
parameters) or FO File input alone.
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.commons.logging.Log
the loggerprotected File
original source file -
Constructor Summary
ConstructorDescriptionInputHandler
(File fofile) Constructor for FO inputInputHandler
(File xmlfile, File xsltfile, Vector params) Constructor for XML->XSLT->FO input -
Method Summary
Modifier and TypeMethodDescriptionvoid
createCatalogResolver
(FOUserAgent userAgent) Creates a catalog resolver and uses it for XML parsing and XSLT URI resolution.protected Source
Creates a Source for the main input file.protected Source
Creates a Source for the selected stylesheet.void
void
void
renderTo
(FOUserAgent userAgent, String outputFormat) Renders the pre-setup document.void
renderTo
(FOUserAgent userAgent, String outputFormat, OutputStream out) Generate a document, given an initialized Fop objectvoid
transformTo
(OutputStream out) In contrast to render(Fop) this method only performs the XSLT stage and saves the intermediate XSL-FO file to the output file.protected void
transformTo
(Result result) Transforms the input document to the input format expected by FOP using XSLT.void
-
Field Details
-
sourcefile
original source file -
log
protected org.apache.commons.logging.Log logthe logger
-
-
Constructor Details
-
InputHandler
Constructor for XML->XSLT->FO input- Parameters:
xmlfile
- XML filexsltfile
- XSLT fileparams
- Vector of command-line parameters (name, value, name, value, ...) for XSL stylesheet, null if none
-
InputHandler
Constructor for FO input- Parameters:
fofile
- the file to read the FO document.
-
-
Method Details
-
renderTo
public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out) throws FOPException Generate a document, given an initialized Fop object- Parameters:
userAgent
- the user agentoutputFormat
- the output format to generate (MIME type, see MimeConstants)out
- the output stream to write the generated output to (may be null if not applicable)- Throws:
FOPException
- in case of an error during processing
-
renderTo
Renders the pre-setup document.- Specified by:
renderTo
in interfaceRenderable
- Parameters:
userAgent
- the user agentoutputFormat
- the output format to generate (MIME type, see MimeConstants)- Throws:
FOPException
- if the FO processing fails
-
transformTo
In contrast to render(Fop) this method only performs the XSLT stage and saves the intermediate XSL-FO file to the output file.- Parameters:
out
- OutputStream to write the transformation result to.- Throws:
FOPException
- in case of an error during processing
-
createMainSource
Creates a Source for the main input file. Processes XInclude if available in the XML parser.- Returns:
- the Source for the main input file
-
createCatalogResolver
Creates a catalog resolver and uses it for XML parsing and XSLT URI resolution. Tries the Apache Commons Resolver, and if unsuccessful, tries the same built into Java 6.- Parameters:
userAgent
- the user agent instance
-
createXSLTSource
Creates a Source for the selected stylesheet.- Returns:
- the Source for the selected stylesheet or null if there's no stylesheet
-
transformTo
Transforms the input document to the input format expected by FOP using XSLT.- Parameters:
result
- the Result object where the result of the XSL transformation is sent to- Throws:
FOPException
- in case of an error during processing
-
warning
- Specified by:
warning
in interfaceErrorListener
-
error
- Specified by:
error
in interfaceErrorListener
-
fatalError
- Specified by:
fatalError
in interfaceErrorListener
- Throws:
TransformerException
-