Package eu.bandm.tools.d2d2.base
Class BatchProcessor
java.lang.Object
eu.bandm.tools.d2d2.base.BatchProcessor
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents one transformation job, with all its parameters, to be applied to multiple d2d source file inputs. -
Field Summary
Modifier and TypeFieldDescription(package private) final int
(package private) final Text2Udom.ErrorStrategy
Used for parsing all d2d sources.static final String
Name of the files or pseudo-files for extracted xslt transformations.static final String
Will be replaced by a central substring of the name of the processed document to derive output file names.(package private) final BatchProcessor.Job[]
All translations wanted for one d2d source input file.(package private) final int
Used for all printed files.(package private) final Map<Transformation,
LocationMap<@Opt XMLDocumentIdentifier, @Opt XMLDocumentIdentifier>> Location Maps when extracting transformation code.(package private) final ModuleRegistry
Used for loading all modules.protected final MessageReceiver<SimpleMessage<@Opt XMLDocumentIdentifier>>
Evidentprotected final MessageCounter
Evident(package private) final MessageReceiver<SimpleMessage<String>>
Derived message receiver with special location type.(package private) final MessageReceiver<SimpleMessage<?>>
Derived message receiver with special location type.static final NamespaceName
Style-sheet parameter value to suppress xml declaration.(package private) int
Count errors for grouping them.(package private) final boolean
Whether also incomplete and partially erroneuous input files shall be translated.(package private) final Map<ResolvedModule,
Map<BatchProcessor.Job, @Opt Transformation>> Result of rule extraction and compilation.(package private) final TransformationCache
Single instance cache for xslt source applied to global parameters.(package private) final Transformation.Modifiers
Modifiers for the txsl execution.(package private) final boolean
Whether to write the generated xslt transformations to two disk files, in ".xslt.d2d" and ".xslt" format.(package private) final @Opt SimpleFilePattern
The rule to derive the file name to stre the xml representations of the parsed d2d sources.(package private) final Trace
Single instance, controls the tracing of the txsl xslt processor. -
Constructor Summary
ConstructorDescriptionBatchProcessor
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, ModuleRegistry modulereg, Text2Udom.ErrorStrategy errorStrategy, Transformation.Modifiers txsl_modifiers, Trace xsltTrace, int debuglevel, boolean writeIntermediateXsltCodeToFile, boolean partialDocs, @Opt SimpleFilePattern xmlOutputFilePattern, int lineWidth, BatchProcessor.Job... jobs) Only Constructor. -
Method Summary
Modifier and TypeMethodDescriptionService access point: process the d2d source text and return the results in a Map object.Service access point: process the d2d source text and return the results in a Map object and write it to files.Service access point: process the d2d source text and return the results in a Map object.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.protected void
Evidentprotected void
Evident(package private) String
errText()
Convert the existance of new errors into a text message.protected void
Evident(package private) boolean
Evidentprotected @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.protected void
Evidentprotected void
Evidentprotected void
Evident(package private) void
Update error counteroldErrs
for grouping error messages.protected void
Print all non-zero message counters to console.void
Service access point: process the d2d source text and write the results to disk files.void
Service access point: process the d2d source text and write the results to disk files.protected void
Evident
-
Field Details
-
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
Name of the files or pseudo-files for extracted xslt transformations.- See Also:
-
nsname_omitXmlDeclaration
Style-sheet parameter value to suppress xml declaration. -
moduleRegistry
Used for loading all modules. -
errorStrategy
Used for parsing all d2d sources. (these are the text input and the xslt fragments from the ddf definition.) -
txsl_modifiers
Modifiers for the txsl execution. -
xsltTrace
Single instance, controls the tracing of the txsl xslt processor. -
debuglevel
final int debuglevel -
writeIntermediateXsltCodeToFile
final boolean writeIntermediateXsltCodeToFileWhether 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 usingfilename_template_transformations
. -
partialDocs
final boolean partialDocsWhether also incomplete and partially erroneuous input files shall be translated. -
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 lineWidthUsed for all printed files. -
jobs
All translations wanted for one d2d source input file. -
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
Derived message receiver with special location type. Neded for sax-output Udom2Sax. -
oldErrs
int oldErrsCount 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
final Map<Transformation,LocationMap<@Opt XMLDocumentIdentifier, locMaps@Opt XMLDocumentIdentifier>> Location Maps when extracting transformation code. -
transformationsCache
Single instance cache for xslt source applied to global parameters.
-
-
Constructor Details
-
BatchProcessor
public BatchProcessor(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, ModuleRegistry modulereg, Text2Udom.ErrorStrategy errorStrategy, Transformation.Modifiers txsl_modifiers, Trace xsltTrace, int debuglevel, boolean writeIntermediateXsltCodeToFile, boolean partialDocs, @Opt @Opt SimpleFilePattern xmlOutputFilePattern, int lineWidth, BatchProcessor.Job... jobs) Only Constructor. All parameters are stored and are equally valid for all files which will subsequently be translated by this instance.
-
-
Method Details
-
error
Evident -
error
Evident -
failure
Evident -
warning
Evident -
log
Evident -
logStart
Evident -
logEnd
Evident -
printErrorCounter
protected void printErrorCounter()Print all non-zero message counters to console. -
hasErrors
boolean hasErrors()Evident -
newErrorGroup
void newErrorGroup()Update error counteroldErrs
for grouping error messages. -
errText
String errText()Convert the existance of new errors into a text message. -
toFile
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
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
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
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 parselocalName
- 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 translatejob
- 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 translatejob
- 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
-