org.apache.fop.cli

## Class InputHandler

- java.lang.Object
- - org.apache.fop.cli.InputHandler

- All Implemented Interfaces:
    javax.xml.transform.ErrorListener, Renderable
  Direct Known Subclasses:
    AreaTreeInputHandler, IFInputHandler, ImageInputHandler

      public class InputHandler
      extends java.lang.Object
      implements javax.xml.transform.ErrorListener, Renderable

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.commons.logging.Log` | `log` the logger
    `protected java.io.File` | `sourcefile` original source file

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputHandler(java.io.File fofile)` Constructor for FO input
    `InputHandler(java.io.File xmlfile, java.io.File xsltfile, java.util.Vector params)` Constructor for XML->XSLT->FO input

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createCatalogResolver(FOUserAgent userAgent)` Creates a catalog resolver and uses it for XML parsing and XSLT URI resolution.
    `protected javax.xml.transform.Source` | `createMainSource()` Creates a Source for the main input file.
    `protected javax.xml.transform.Source` | `createXSLTSource()` Creates a Source for the selected stylesheet.
    `void` | `error(javax.xml.transform.TransformerException exc)`
    `void` | `fatalError(javax.xml.transform.TransformerException exc)`
    `void` | `renderTo(FOUserAgent userAgent, java.lang.String outputFormat)` Renders the pre-setup document.
    `void` | `renderTo(FOUserAgent userAgent, java.lang.String outputFormat, java.io.OutputStream out)` Generate a document, given an initialized Fop object
    `void` | `transformTo(java.io.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(javax.xml.transform.Result result)` Transforms the input document to the input format expected by FOP using XSLT.
    `void` | `warning(javax.xml.transform.TransformerException exc)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### sourcefile

          protected java.io.File sourcefile

      original source file

    - #### log

          protected org.apache.commons.logging.Log log

      the logger

  - ### Constructor Detail

    - #### InputHandler

          public InputHandler(java.io.File xmlfile,
                              java.io.File xsltfile,
                              java.util.Vector params)

      Constructor for XML->XSLT->FO input
      Parameters:
        `xmlfile` - XML file
        `xsltfile` - XSLT file
        `params` - Vector of command-line parameters (name, value, name, value, ...) for XSL stylesheet, null if none

    - #### InputHandler

          public InputHandler(java.io.File fofile)

      Constructor for FO input
      Parameters:
        `fofile` - the file to read the FO document.

  - ### Method Detail

    - #### renderTo

          public void renderTo(FOUserAgent userAgent,
                               java.lang.String outputFormat,
                               java.io.OutputStream out)
                        throws FOPException

      Generate a document, given an initialized Fop object
      Parameters:
        `userAgent` - the user agent
        `outputFormat` - 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

          public void renderTo(FOUserAgent userAgent,
                               java.lang.String outputFormat)
                        throws FOPException

      Renders the pre-setup document.
      Specified by:
        `renderTo` in interface `Renderable`
      Parameters:
        `userAgent` - the user agent
        `outputFormat` - the output format to generate (MIME type, see MimeConstants)
      Throws:
        `FOPException` - if the FO processing fails

    - #### transformTo

          public void transformTo(java.io.OutputStream out)
                           throws FOPException

      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

          protected javax.xml.transform.Source 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

          public void createCatalogResolver(FOUserAgent userAgent)

      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

          protected javax.xml.transform.Source createXSLTSource()

      Creates a Source for the selected stylesheet.
      Returns:
        the Source for the selected stylesheet or null if there's no stylesheet

    - #### transformTo

          protected void transformTo(javax.xml.transform.Result result)
                              throws FOPException

      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

          public void warning(javax.xml.transform.TransformerException exc)

      Specified by:
        `warning` in interface `javax.xml.transform.ErrorListener`

    - #### error

          public void error(javax.xml.transform.TransformerException exc)

      Specified by:
        `error` in interface `javax.xml.transform.ErrorListener`

    - #### fatalError

          public void fatalError(javax.xml.transform.TransformerException exc)
                          throws javax.xml.transform.TransformerException

      Specified by:
        `fatalError` in interface `javax.xml.transform.ErrorListener`
      Throws:
        `javax.xml.transform.TransformerException`

Copyright 1999-2021 The Apache Software Foundation. All Rights Reserved.