Class BatchProcessor

java.lang.Object
eu.bandm.tools.d2d2.base.BatchProcessor

public class BatchProcessor extends Object
Batch processing of d2d sources into different back-ends, using BandMs' own "txsl" implementation of xslt 1_0. Realizes more efficient processing of more than one input file into more than one output format without module caching, since the start-up phase must only be executed once.
  • Field Details

    • filenameStemPlaceholder

      public static final String filenameStemPlaceholder
      Will be replaced by a central substring of the name of the processed document to derive output file names.
      See Also:
    • filename_template_transformations

      public static final String filename_template_transformations
      Name of the files or pseudo-files for extracted xslt transformations.
      See Also:
    • nsname_omitXmlDeclaration

      public static final NamespaceName nsname_omitXmlDeclaration
      Style-sheet parameter value to suppress xml declaration.
    • moduleRegistry

      final ModuleRegistry moduleRegistry
      Used for loading all modules.
    • errorStrategy

      final Text2Udom.ErrorStrategy errorStrategy
      Used for parsing all d2d sources. (these are the text input and the xslt fragments from the ddf definition.)
    • txsl_modifiers

      final Transformation.Modifiers txsl_modifiers
      Modifiers for the txsl execution.
    • xsltTrace

      final Trace xsltTrace
      Single instance, controls the tracing of the txsl xslt processor.
    • debuglevel

      final int debuglevel
    • writeIntermediateXsltCodeToFile

      final boolean writeIntermediateXsltCodeToFile
      Whether to write the generated xslt transformations to two disk files, in ".xslt.d2d" and ".xslt" format. This is mainly for debugging purposes. The name of the files are synthesized using filename_template_transformations.
    • partialDocs

      final boolean partialDocs
      Whether also incomplete and partially erroneuous input files shall be translated.
    • xmlOutputFilePattern

      @Opt final @Opt SimpleFilePattern xmlOutputFilePattern
      The rule to derive the file name to stre the xml representations of the parsed d2d sources. If ==null, no such xml file will be written.
    • lineWidth

      final int lineWidth
      Used for all printed files.
    • jobs

      final BatchProcessor.Job[] jobs
      All translations wanted for one d2d source input file.
    • msg_counter

      protected final MessageCounter msg_counter
      Evident
    • msg

      Evident
    • msgMEMSTR

      Derived message receiver with special location type. Neded for Text2Udom, (as applied to d2d input sources and xslt fragments).
    • msgOBJECT

      final MessageReceiver<SimpleMessage<?>> msgOBJECT
      Derived message receiver with special location type. Neded for sax-output Udom2Sax.
    • oldErrs

      int oldErrs
      Count errors for grouping them.
    • transformations

      Result of rule extraction and compilation. While the target parameters (tdom, target key) are the same for each Job instance in each particular instance of Batch, the "d2d document types" of the sources may be different, and thus the extracted xslt code and thus the compiled xslt transformation object. This type is represented by the resulting ResolvedModule, which contains the definition of the top element. So we have a two-step mapping:
      (loaded module as the type of parsed d2d input) -> (Job instance) -> (xslt Transformation object)
    • locMaps

      Location Maps when extracting transformation code.
    • transformationsCache

      final TransformationCache transformationsCache
      Single instance cache for xslt source applied to global parameters.
  • Constructor Details

  • Method Details

    • error

      protected void error(String s, Object... args)
      Evident
    • error

      protected void error(Throwable ex, String s, Object... args)
      Evident
    • failure

      protected void failure(String s, Object... args)
      Evident
    • warning

      protected void warning(String s, Object... args)
      Evident
    • log

      protected void log(String s, Object... args)
      Evident
    • logStart

      protected void logStart(String s, Object... args)
      Evident
    • logEnd

      protected void logEnd(String s, Object... args)
      Evident
    • printErrorCounter

      protected void printErrorCounter()
      Print all non-zero message counters to console.
    • hasErrors

      boolean hasErrors()
      Evident
    • newErrorGroup

      void newErrorGroup()
      Update error counter oldErrs for grouping error messages.
    • errText

      String errText()
      Convert the existance of new errors into a text message.
    • toFile

      public void toFile(File input)
      Service access point: process the d2d source text and write the results to disk files. The written files will be in the same directory as the input file.
      Parameters:
      input - must be an absolute path to the d2d source.
    • toFile

      public void toFile(File input, File outputDirectory)
      Service access point: process the d2d source text and write the results to disk files.
      Parameters:
      input - must be an absolute path to the d2d source.
      outputDirectory - where to put the result files
    • apply

      public Map<BatchProcessor.Job,Object> apply(String input, String localname)
      Service access point: process the d2d source text and return the results in a Map object.
      Parameters:
      input - contains the d2d source.
      localname - a fictional file name, used for error messaging and deriving the names of the output files.
      Returns:
      a Map to either Udom result structures or Strings in case of mere-text target format.
    • apply

      public Map<BatchProcessor.Job,Object> apply(File input) throws IOException
      Service access point: process the d2d source text and return the results in a Map object.
      Parameters:
      input - must be a path (relative or absolute) to the d2d source.
      Returns:
      a Map to either Udom result structures or Strings in case of mere-text target format.
      Throws:
      IOException
    • apply

      public Map<BatchProcessor.Job,Object> apply(Reader input, String localName, @Opt @Opt File outputDirectory)
      Service access point: process the d2d source text and return the results in a Map object and write it to files.
      Parameters:
      input - the input to parse
      localName - a fictional file name, used for error messaging and deriving the names of the output files.
      outputDirectory - where to put the result files. May be ==null for no file writing.
      Returns:
      a Map to either Udom result structures or Strings in case of mere-text target format.
    • loadTransformationForModule

      @Opt protected @Opt Transformation loadTransformationForModule(ResolvedModule mod, BatchProcessor.Job job, String dateNow, String fileBasis)
      Constructs the transformation xslt code for the given d2d source text module and the transformation described in one job of the command line options.
      Parameters:
      mod - resolved module containing the definition of the top-most element to translate
      job - the transformation description, giving target name, target tdom, target file name etc.
      dateNow - for the creation comment in the generated files (=side effect for debugging)
      fileBasis - directory for the generated files (=side effect for debugging)
      Returns:
      cached result or null in case of error (signalled now or already earlier)
    • do_loadTransformationForModule

      @Opt protected @Opt Transformation do_loadTransformationForModule(ResolvedModule mod, BatchProcessor.Job job, String dateNow, String fileBasis)
      Constructs the transformation xslt code for the given d2d source text module and the transformation described in one job in the CLI options.
      Parameters:
      mod - resolved module containing the definition of the top-most element to translate
      job - the transformation description, giving target name, target tdom, target file name etc.
      dateNow - for the creation comment in the generated files (=side effect for debugging)
      fileBasis - dirctory for the generated files (=side effect for debugging)
      Returns:
      null in case of error