Class ScriptTransformer

java.lang.Object
com.norconex.importer.handler.transformer.impl.ScriptTransformer
All Implemented Interfaces:
Configurable<ScriptTransformerConfig>, ConfigurableDocHandler<ScriptTransformerConfig>, DocHandler

public class ScriptTransformer extends Object implements ConfigurableDocHandler<ScriptTransformerConfig>

Transform incoming documents using a scripting language.

Refer to ScriptRunner for more information on using a scripting language with Norconex Importer.

How to transform documents with scripting:

The following are variables made available to your script for each document:

  • reference: Document unique reference as a string.
  • content: Document content, as a string (of maxReadSize length).
  • metadata: Document metadata as an Properties object.
  • parsed: Whether the document was already parsed, as a boolean.
  • sectionIndex: Content section index if it had to be split (as per maxReadSize), as an integer.

The expected return value from your script is a string holding the modified content.

Usage examples:

The following examples replace all occurrences of "Alice" with "Roger" in a document content.

See Also: